我對flexbox有點複雜的問題。基本上,我的演示在Chrome中運行,但不在Firefox中運行。下面是我的HTML代碼:絕對定位干擾在Flexbox中的flexbox定位
<div class="flex-main-container">
<img src="http://www.modifiedstreetcars.com/sites/default/files/styles/carousel_circle/public/Nissan-GTR-White-Custom1.jpg?itok=RTxhTPOv" alt="">
<img src="http://www.buntycars.com/contents/member/buntycars/photos/Hot-Modified-Car-Wallpape-721c6.jpg" alt="">
<figure>
<img src="http://modscar.net/wp-content/uploads/2016/04/30-MODIFIED-CARS-ARE-SHINING-AT-THE-ZOMBIE-APOCALYPSE.jpg" alt="">
<figcaption>explanatory caption</figcaption>
</figure>
<figure>
<img src="http://modscar.net/wp-content/uploads/2016/04/30-MODIFIED-CARS-ARE-SHINING-AT-THE-ZOMBIE-APOCALYPSE.jpg" alt="">
<figcaption>explanatory caption</figcaption>
</figure>
</div>
現在的文件有以下談談在Flex容器定位元素:
由於它是亂流,一個絕對定位的孩子flex 容器不參與彈性佈局。
現在我已經定位的兩個元件,即,圖像絕對像這樣:
.flex-main-container > img:nth-of-type(1) {
position: absolute;
left: 0;
top: 0;
}
.flex-main-container > img:nth-of-type(2) {
position: absolute;
left: 100px;
top: 150px;
}
現在容器我有以下代碼上:
.flex-main-container {
background: #eee;
display: flex;
height: 500px;
align-items:flex-start;
justify-content:space-between;
flex-direction: column;
}
現在我期望剩下的元素散開垂直cally,因爲我在主容器上有justify-content:space-between
。我確實在Chrome中獲得了期望的行爲。見下面的截圖:
但在Firefox到底是什麼錯誤你看到下面
請注意,在Firefox中的黑車圖像不對齊右上就像它在Chrome中一樣。不知何故,在Firefox中,絕對定位的元素似乎仍然會干擾其餘元素的定位,我認爲這不應該是這種情況。
有人可以解釋爲什麼會發生這種情況嗎?爲什麼Firefox允許絕對定位的元素干擾其他靜態元素的定位?
P.S.這是一個「爲什麼」的問題。我不只是尋找一個「黑客」來解決這個問題,但我真的很感興趣,爲什麼會發生這種情況。
謝謝。
看起來像[Flexbox中的Firefox:物品未正確排列](http://stackoverflow.com/q/32532377/1529630) – Oriol