2014-02-28 61 views
1

我使用的是引導中的變化,這包含規則垂直對齊:包含分區的位置

img { 
    vertical-align: middle; 
} 

對於下面的CSS和標記,視圖不會呈現我所想要的(含的div圖像不排隊正確):

HTML

<div class="detail"> 
    <div class="detail_image_container"> 
     <div class="main_image_container"> 
     <img src="http://dummyimage.com/300" class="main_image" /> 
     </div> 
     <ul class="thumbnails"> 
     <li><img src="http://dummyimage.com/50" class="thumbnail selected"/></li> 
     <li><img src="http://dummyimage.com/50" class="thumbnail "/></li> 
     <li><img src="http://dummyimage.com/50" class="thumbnail "/></li> 
     <li><img src="http://dummyimage.com/50" class="thumbnail "/></li> 
     <li><img src="http://dummyimage.com/50" class="thumbnail "/></li> 
     </ul> 
    </div> 
    <div class="detail_info_panel"> 
    <div>SOME TEXT HERE</div> 
    <div>SOME TEXT HERE</div> 
    <div>SOME TEXT HERE</div> 
    <div>SOME TEXT HERE</div> 
    </div> 
</div> 

CSS:

div.detail>div { 
    display: inline-block; 
} 

.detail_image_container>* { 
    display: inline-block; 
} 

ul { 
    list-style-type: none; 
} 

li img { 
    margin: 3px; 
    border: 1px solid black; 
} 

li img.selected { 
    border: 3px solid black; 
} 

下面是它的外觀withwithoutimg {vertical-align:middle;}

爲什麼會發生這種情況,我該如何解決?

回答

1

定義您

.detail_image_container>* { 
vertical-align: middle; 
} 

Demo

+0

這似乎解決我的問題,但你能添加一個解釋,爲什麼? – bdares

+2

是的你定義了display:inline-block;但不定義垂直對齊;所以如果你定義你的HTML元素顯示:inline-block;請根據您的要求定義vertical-align:top,middle,bottom任意一個 –