开发者

css how to make <a> text align bottom?

How how to make <a> text align bottom? I have added height = line-height, and vertical-alig开发者_如何学Gon:bottom; but the text still in the middle of the div. How to do? Thanks

Test in http://jsfiddle.net/BanAz/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
#layer{width:198px;height:48px;line-height:48px;border:1px #000 solid;vertical-align:bottom;}
#layer a{text-decoration:none;}
</style>
</head>
<body>
<div id="layer">
<a href="#">menu</a>
</div>
</body>
</html>


Options include:

  • Remove line-height: 48px and add display: table-cell to #layer: http://jsfiddle.net/jgQ9k/1/
    Note that this won't work for IE7, because display: table-cell isn't supported.
  • Use a large line-height: http://jsfiddle.net/jgQ9k/2/

And the method I would actually use:

  • Add position: relative to #layer, and position:absolute; bottom:0 to #layer a:
    http://jsfiddle.net/jgQ9k/3/


The height size (48px) is equal to line-height size (48px). Try to increase the height size, and you will see the css properties work fine and the text will be positioned on the bottom


#layer {
    display: table-cell;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜