2016-07-25 31 views
2

使用display:flex;顯示Flex是不是在IE

即工作邊做工精細,我試圖做的圖像居中對齊在<div class="product-image-area">,Firefox和Chrome,但不是在IE瀏覽器。

CSS

.horizontal { 
    display: flex; 
    justify-content: center; 
} 

.vertical { 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
} 

小提琴這裏:在邊緣,鍍鉻JS Fiddle

結果和Firefox enter image description here

結果在IE

enter image description here

+1

的http:// caniuse.com/#feat=flexbox –

+0

你可以嘗試以% –

+0

@JeysinghAnbu的寬度顯示內聯塊,你可以試試這個http://jsfiddle.net/ynk5ccmp/5/ –

回答

3

刪除img-responsive CSS類從img並添加vertical

.horizontal { 
    height: 150px; 
    line-height: 150px; 
    text-align: center; 
} 

.vertical { 
    vertical-align: middle; 
    max-height: 150px; 
    max-width: 100%; 
} 

更新Fiddle Here

3

只有IE 11部分支持flexbox。

在IE瀏覽器就可以使用兒童display: table;爲家長和display: table-cell;vertical-align: middle;

.horizontal { 
    display: table; 
    width: 100%; 
    text-align: center; 
} 

.vertical { 
    display: table-cell; 
    vertical-align: middle; 
} 
+0

您的預期成果是什麼? 我在IE10上測試了這個和img是垂直對齊的http://jsfiddle.net/ynk5ccmp/13/ –

+0

@Mohammed Reza,謝謝,現在寬度還行。但是當我改變高度時,兩者都是不同的高度。期望是在同一個高度。我附上小提琴在這裏http://jsfiddle.net/ynk5ccmp/15/ –

+0

@JeysinghAnbu你想要在盒子或圖像上有相同的高度嗎? –