css how to make text align bottom?

2019-05-18 15:20发布

How how to make <a> text align bottom? I have added height = line-height, and vertical-align: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>

3条回答
Viruses.
2楼-- · 2019-05-18 15:49
#layer {
    display: table-cell;
}
查看更多
倾城 Initia
3楼-- · 2019-05-18 16:01

Options include:

And the method I would actually use:

查看更多
4楼-- · 2019-05-18 16:01

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

查看更多
登录 后发表回答