我工作的一个移动网站,我有几个与文本到右边显示一个小缩略图页面:http://sunsetwesterngardencollection.com/mobile/the-collection当文本不在表格单元格中时,如何垂直排列文本?
缩略图位置很好,但文本挑战。我做了一些研究并找到了一个选择,但它似乎不能正常工作。
下面是内容的HTML:
<ul id="plants">
<li class="plant">
<a href="http://sunsetwesterngardencollection.com/mobile/plant/amistad-salvia"><img src="http://sunsetwesterngardencollection.com/photos/thumbnails/salvia_amistad_thumb.jpg" alt="‘Amistad’ Salvia" />
<span class="plant-name">‘Amistad’ Salvia</span></a>
<div class="orange-slice"></div>
</li>
<li class="plant">
<a href="http://sunsetwesterngardencollection.com/mobile/plant/black-adder-phormium"><img src="http://sunsetwesterngardencollection.com/photos/thumbnails/phormium_black_adder_thumb.jpg" alt="‘Black Adder’ Phormium" />
<span class="plant-name">‘Black Adder’ Phormium</span></a>
<div class="orange-slice"></div>
</li>
<li class="plant">
<a href="http://sunsetwesterngardencollection.com/mobile/plant/blue-riding-hood-penstemon"><img src="http://sunsetwesterngardencollection.com/photos/thumbnails/penstemon_blue_riding_hood_thumb.jpg" alt="‘Blue Riding Hood’ Penstemon" />
<span class="plant-name">‘Blue Riding Hood’ Penstemon</span></a>
<div class="orange-slice"></div>
</li>
</ul>
这里是CSS:
ul#plants li {
width: 100%;
height: auto;
position: relative;
}
.orange-slice {
width: 100%;
height: 2px;
clear: both;
background: #e1562e;
}
ul#plants li img { float: left; width: 20%; margin: 0; }
ul#plants li span,
ul#plants li span a:link,
ul#plants li span a:visited {
color: #e1562e;
font-size: 1.3em;
font-weight: 500;
position: absolute;
top: 25%;
left: 23%;
text-transform: uppercase;
display: table-cell;
vertical-align: middle;
}
什么是垂直对齐文本时,它不是在一个表格单元格的正确方法?
谢谢!
相关:http://stackoverflow.com/questions/4005309/div-table-cell-vertical-align-not-working很好的解释: http://css-tricks.com/centering-in-the-unknown/ –