我有一個頁面,我按照它們所屬的類別並排顯示圖像,每個圖像數組以它所屬的類別開頭。圖片的高度差異在&之間,但放入絕對高度爲330px的div中。將div與第一個垂直居中的div對齊
CSS:
.front-index {
margin: 0 1em 0 2em;
}
.front-work {
margin: 0 2em 2em 0;
display: table;
width: 66px;
position: relative;
height: 330px;
background-color:#f0f0f0;
}
.front-work img {
margin: .3em 0 .3em 0;
}
.wraptocenter {
display: table-cell;
text-align: center;
vertical-align: middle;
}
.wraptocenter * {
vertical-align: middle;
}
.front-index,
.front-work {
float: left;
}
HTML:
<div class="front-index"><p>How to get<br /> this text on the same line with<br /> yellow image on the right?</p></div>
<div class="front-work">
<div class="wraptocenter">
<img width="162" height="250" src="http://images.fanpop.com/images/image_uploads/Yellow-Wallpaper-yellow-646738_800_600.jpg"/>
</div>
</div>
<div class="front-work">
<div class="wraptocenter">
<img width="250" height="166" src="http://www.takenseriouslyamusing.com/wp-content/uploads/2012/08/Blue.png"/>
</div>
</div>
…
的jsfiddle:http://jsfiddle.net/rCAKa/9/
我想文本在同一行對齊作爲第一圖像正確的。
我想到的是,這可能是這應該在jQuery中完成。 IE瀏覽器。以某種方式測量從.front-work div內部頂部的圖像距離,然後將該值作爲內聯代碼(top:whatever px)分配給.front-index div。
也許有人會遇到這樣的問題,並且知道解決這類問題的方法嗎? CSS或JS。
哪裏是黃色圖像? – 2013-02-23 12:52:33