Jump to content

Text position inseda a div


keevitaja

Recommended Posts

Hi Keevitja -- I don't understand your first question, but a trick i use to center my text vertically is as follows using the CSS font-property 'font'. Here is an example:

 

 

font: normal 10px/26px

 

That specifies the font size as 10 pixels, but centers it in a div of 30 pixels (I don't know why this works exactly but it does - you have to play with it to get your sizing - but the lower the second number, the higher the type will sit in the box basically. I hope I'm explaining that well enough for you to understand (and i'm a newb, so take my advice for what it's worth).

 

-Chez

Link to comment
Share on other sites

how can i make textbox go right and text inside a textbox also right + middle

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<style type="text/css">

<!--

body {

margin-left: 0px;

margin-top: 0px;

margin-right: 0px;

margin-bottom: 0px;

}

#container {

background-color: #99F;

height: 300px;

width: 500px;

margin-top: 20px;

margin-left: 40px;

text-align: right;

}

#textbox {

width:200px;

height:150px;

background-color:#993;

text-align: right;

vertical-align: middle;

}

-->

</style>

</head>

<body>

<div id="container">

  <div id="textbox">this is a text box</div>

</div>

</body>

</html>

Link to comment
Share on other sites

You can use paragraph tags and float.

 

p.left-text {
float: left;
width: (the number you put here must be less than half the width of your div);
}

p.right-text {
float: right;
width: (the number you put here must be less than half the width of your div);
}

<div id='nameofyourdiv'>
<p class='right-text'>Right Text</p>
<p class='left-text'>Left Text</p>
</div>

I have tested the code and it works.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.