Forum Moderators: not2easy
<html>
<head>
<title>place div</title>
</head>
<body>
<div id="div_one" style="top: 100px; position: absolute; left: 150px;">
<p>Text div</p>
</div>
</body>
</html>
If I am not wrong, 100% css layout don't support vertial-align=middle property. However there is a work-around using linewidth, don't remember it right now though :(
*edit*
Here is the work-around link : [student.oulu.fi...] (not sure if mods will allow it.. but if they keep it, the link is pretty handy)
No.
I want to put a text in div. Text should be aligned in the middle of the div.<table>
<tr>
<td valign="middle">
some text here
</td>
</tr>
</table>Here's text's alignment without CSS. But I want to have similar effect with CSS. Don't know how.
Unfortunately, this is a hard thing to do with CSS2. (CSS3 is supposed to have this problem resolved...but that's not the issue now, is it? ;) )
To do it with text, you must simply do something like so:
<div id="wrapper">
<p>some text here</p>
</div>
The CSS to go along with that would be:
#wrapper {
height:100px;
vertical-align:middle;
}p {
font-size:10em;
line-height:10em;
}
This'll make your text align to the center of the div. The thing is that the line-height and font size need to be the same.
Also, this only works with one line of text. If the text ends up wrapping, it won't work. This also does not work with stuff like images and divs - only text.
However, an alternate workaround [jakpsatweb.cz] was posted on the CSS-D list a while back, and I've found it works very nicely.