我試圖將一些文本對齊到底部(用綠色邊框標記),但「vertical-align:bottom」不起作用,「position:absolute; bottom:0 「導致文字堆積在李以外。我究竟做錯了什麼?將菜單文本對齊到底部
的jsfiddle:http://jsfiddle.net/eternal_noob/dog42xeh/
HTML:
<div class="head">
<div class="logo"> <a href="/" title="Back to homepage">
<img src="http://www.dierenasielamsterdam.nl/files/homepage/Poes-virtueel-asiel.jpg">
</a>
</div>
<div class="nav">
<div class="icon-top"> <span>(999)999-9999/(999)999-9999</span>
</div>
<div class="menu">
<ul class="topmenu">
<li><a href="a.php">Abyssinian</a>
</li>
<li><a href="b.php">Munchkin</a>
</li>
<li><a href="c.php">Persian</a>
</li>
<li><a href="d.php">Siamese</a>
</li>
<li><a href="e.php">About</a>
</li>
</ul>
</div>
</div>
CSS:
.head {
text-align: center;
height: 150px
}
.head:before {
content:'';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -0.25em
}
.logo {
display: inline-block;
vertical-align: middle;
height: 100px;
width: 350px;
}
.nav {
display: inline-block;
vertical-align: middle;
height: 100px;
width: 600px;
}
.icon-top {
line-height:29px;
padding-right:20px;
color:#333;
font-size:15px;
text-align:right;
}
.menu {
position: relative;
text-align:right;
}
.menu-header {
height:50px;
}
.topmenu {
display: inline-block;
height:65px;
margin:0;
padding:0;
font-size: 20px;
}
.topmenu li {
display: inline-block;
height:100%;
list-style:none;
margin-left:20px;
border: solid 1px green;
}
.topmenu li a {
color: #000000;
vertical-align:text-bottom;
}
.topmenu li a:hover {
color:#b574d4;
}
如果你不怕JS的這也適用:http://jsfiddle.net/ctwheels/dog42xeh/3/ – ctwheels 2014-08-28 18:04:56