2015-05-15 35 views
2

我試圖使用this template實現與Flexbox內Bootstrap 3列垂直對齊。但在Firefox中,我使用響應式圖像獲得了奇怪的結果。他們身高過大,超出比例,超過100%。您可以在Firefox中檢查this JSFiddle(35)。Bootstrap + Flex + Firefox = bug

CSS 
.vertical-align { 
    display: flex; 
    flex-direction: row; 
} 

.vertical-align > [class^="col-"], 
.vertical-align > [class*=" col-"] { 
    display: flex; 
    align-items: center;  /* Align the flex-items vertically */ 
    justify-content: center; /* Optional, to align inner flex-items 
           horizontally within the column */ 
} 
HTML 
<div class="container"> 
    <div class="row vertical-align"> 
    <div class="col-xs-6"> 
     <p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary,</p> 
    </div> 
    <div class="col-xs-6"> 
     <img src="http://placehold.it/1400x1000" class="img-responsive" /> 
    </div> 
    </div> 
</div> 

任何想法如何解決這個問題?

回答

2

顯然,「img-responsive」類和Firefox並不總是相處的。您可以通過在課程中添加width: 100%來解決此問題:

.img-responsive { 
    width: 100%; 
} 
+0

爲什麼會發生這種情況?這是一個錯誤嗎? – dandaka

+1

@dandaka - [這篇文章](http://www.telegraphicsinc.com/2014/03/bootstrap-img-responsive-not-working-in-firefox/)說它必須做絕對定位,但是因爲你'不要這樣做,我不知道爲什麼它發生在這裏。 – BSMP

+0

如果你這樣做,那麼這個類的所有圖像將會擴展以適合它的容器,如果需要的話,它會超過它自己的原始大小。這可能不是你想要的。您需要定位特定的受影響的圖像;在這種情況下,'.vertical-align .img-responsive'。 – Pere