css如何制作< a>文字对齐底部? [英] css how to make <a> text align bottom?
本文介绍了css如何制作< a>文字对齐底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何让< a>
文字对齐底部?我添加了 height =
line-height
和 vertical-align:bottom; code>但文本仍然在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 =#>菜单< / a>
< / div>
< / body>
< / html>
解决方案
选项包括:
- 删除
line-height:48px
并添加display:table-cell
到#layer
:
http: //jsfiddle.net/jgQ9k/1/
请注意,这对IE7不起作用,因为display:table-cell
不支持。 - 使用大型
行高
: http://jsfiddle.net/jgQ9k/2/
我将实际使用的方法:
- 添加
位置:相对
至#layer
和position:absolute; bottom:0
到#layer a
:
http://jsfiddle.net/jgQ9k/3/
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>
解决方案
Options include:
- Remove
line-height: 48px
and adddisplay: table-cell
to#layer
: http://jsfiddle.net/jgQ9k/1/
Note that this won't work for IE7, becausedisplay: 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
, andposition:absolute; bottom:0
to#layer a
:
http://jsfiddle.net/jgQ9k/3/
这篇关于css如何制作< a>文字对齐底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文