我已經在這裏和在線閱讀了大量有關如何讓文本和圖像垂直居中的頁面,但我似乎無法管理它。顯然有一些我失蹤了,但什麼?使文本和圖像垂直居中的問題
tr:nth-child(odd) {
background-color: #FFF;
}
tr:nth-child(even) {
background-color: #FFF4E3;
}
#serviceList {
background-color: #FFDEA5;
border: 2px double white;
margin-bottom: 10px;
}
.serviceContentMode {
float: left;
margin: 2px;
width: 70px;
}
.serviceContentNum {
float: left;
margin: 2px;
font-size: 20pt;
width: 75px;
}
.serviceContentOp,
.serviceContentDesc {
font-size: 12pt;
line-height: 150%;
}
.serviceContentOp {
font-weight: bold;
}
.serviceContentDesc {
font-style: italic;
}
<div id="serviceList">
<h1>Services</h1>
<h3>The following services operate in Southend-on-sea:</h3>
<table width="100%" border="0">
<tbody>
<tr>
<td>
<div class="serviceContentMode"><img alt="Wheelchair-accessible bus" src="http://www.travelinesoutheast.org.uk/se/images/means/WheelchairBus.gif" /></div>
<div class="serviceContentNum"><span style="vertical-align:middle;">1</div></span>
<div class="serviceContentOp">Arriva (in Herts and Essex)</div>
<div class="serviceContentDesc">Southend - Hadleigh - South Benfleet - Thundersley - Rayleigh</div>
</td>
</tr>
<tr>
<td>
<div class="serviceContentMode"><img alt="Wheelchair-accessible bus" src="http://www.travelinesoutheast.org.uk/se/images/means/WheelchairBus.gif" /></div>
<div class="serviceContentNum"><span style="vertical-align:middle;">28</div></span>
<div class="serviceContentOp">First in Essex</div>
<div class="serviceContentDesc">Southend - Hadleigh - Thundersley - Benfleet - Pitsea - Basildon</div>
</td>
</tr>
<tr>
<td>
<div class="serviceContentMode"><img alt="Wheelchair-accessible coach" src="http://www.travelinesoutheast.org.uk/se/images/means/Coach.gif">
</div>
<div class="serviceContentNum"><span style="vertical-align:middle;">X5</span></div>
<div class="serviceContentOp">First in Essex</div>
<div class="serviceContentDesc">Southend - Southend Airport - Rayleigh - Chelmsford - Barnston - Stansted Airport</div>
</td>
</tr>
</tbody>
</table>
</div>
我知道vertical-align: middle
目前只在HTML文件應用於<span>
的服務號碼,而不是在CSS,但我已經試過各種不同的組合一切都無濟於事。
那麼我錯過了什麼?
謝謝
你應該修正你的HTML文件第一,它是充滿了錯誤 –
這就是圍繞自帶了瑣細的用的東西得到它的工作,切東西出來,粘貼它放回再次..儘管我認爲「充分」的錯誤可能有點苛刻。這只是三個結束標籤,我錯了。但是,對於我想要達到的目標,沒有什麼不同。 – StuartR143
你有沒有嘗試過常用的技術來垂直對齊div中的項目?這是一個被問到的問題[一噸](http://stackoverflow.com/a/8865463/4124802)。 – Django