0

I am trying to align text at the bottom of a Div and the Middle of a Div. The CSS attribute vertical-align:text-bottom; seems to do nothing?

I have 3 divs and would like to center the div xrLabel1 and the other div xrLabel5 to put the text at the bottom.

I have included some sample code.

Thanks

<!DOCTYPE html>
<html>
    <head>
        <link type="text/css" rel="stylesheet" href="format.css"/>
        <title></title>
    </head>
    <body>
        <div class="TopMargin">
            <div class="xrLabel2">xrLabel2</div>
            <div class="xrLabel1">xrLabel1</div>
            <div class="xrLabel5">xrLabel5</div>
        </div>
    </body>
</html>

The CSS file format.css

.TopMargin
{
position:absolute;
left:0px;
top:0px;
height:92px;
width:650px;
background-color:#808080;
color:#000000;
}

.xrLabel2
{
position:absolute;
left:225px;
top:17px;
height:67px;
width:99px;
background-color:#FFFFFF;
color:#000000;
text-align:center;
vertical-align:text-middle;
font-family:Times New Roman ;font-size:9.75pt;text-decoration:underline;
}

.xrLabel1
{
position:absolute;
left:367px;
top:8px;
height:75px;
width:99px;
background-color:#FFFFFF;
color:#000000;
text-align:right;
vertical-align:text-bottom;
font-family:Times New Roman ;font-size:9.75pt;text-decoration:underline;
}

.xrLabel5
{
position:absolute;
left:75px;
top:8px;
height:75px;
width:99px;
background-color:#FFFFFF;
color:#000000;
text-align:center;
vertical-align:text-top;
font-family:Times New Roman;font-size:9.75pt;
}

3 Answers3

0

Block elements does not support vertical-align as such. You need to set the display attribute to table-cell. Then you can use vertical-align.

http://jsfiddle.net/kuUHV/

F. Müller
  • 2,577
  • 6
  • 30
  • 37
0

You need to use display:table on the parent element, and display:table-cell; vertical-align:bottom; for the children. Example here: http://jsfiddle.net/hAScR/

n1kkou
  • 2,848
  • 2
  • 16
  • 27
-1

You could use text-align:center on the parent element. And a margin-top on the child element.

<div id="outer"> #text-align:center
  <div class="inner">Radom text </div> # margin-top:__
</div>

Fiddle Demo :)

Note: // Don´t use this for responsive Design - when you resize the window the element will stay on the same spot if the element gets to small.

Mr. iC
  • 129
  • 9