css 如何制作 ;文字底部对齐吗?
如何让 文本底部对齐?我添加了
height
= line-height
和 vertical-align:bottom;
但文本仍然位于 div 的中间。怎么办?感谢
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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
选项包括:
line-height: 48px
并将display: table-cell
添加到#layer
:http://jsfiddle.net/jgQ9k/1/
请注意,这不适用于 IE7,因为不支持
display: table-cell
。行高
:http://jsfiddle.net/jgQ9k/2/我实际使用的方法是:
position:relative
添加到#layer
和position:absolute;底部:0
到#layer a
:http://jsfiddle.net/jgQ9k/3/
Options include:
line-height: 48px
and adddisplay: table-cell
to#layer
:http://jsfiddle.net/jgQ9k/1/
Note that this won't work for IE7, because
display: table-cell
isn't supported.line-height
: http://jsfiddle.net/jgQ9k/2/And the method I would actually use:
position: relative
to#layer
, andposition:absolute; bottom:0
to#layer a
:http://jsfiddle.net/jgQ9k/3/
height 尺寸 (48px) 等于 line-height 尺寸 (48px)。尝试增加高度大小,您将看到 css 属性工作正常并且文本将位于底部
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