2016-09-06 48 views
0

我有divdisplay: flex和兩個孩子div說.left.right.left.right的內容大小不同。我想爲孩子設置相同的高度讓孩子的高度在柔性箱內相同

這裏是一個很小的工作代碼

.container{ 
 
\t display: flex; 
 
\t align-items: center 
 
} 
 
.left, .right{ 
 
\t width: 50%; 
 
} 
 
.right{ 
 
\t background: blue; 
 
\t height: 100%; 
 
} 
 
.left{ 
 
\t background: green; 
 
\t height: 100%; 
 
}
<div class="container"> 
 
\t <div class="left"> 
 
\t \t <span>this dis also should have same width as right div</span> 
 
\t </div> 
 
\t <div class="right"> 
 
\t \t orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
\t </div> 
 
</div>

這裏是Fiddle的問題

注意 :無需申請即可享受解決方案g position: absolute因爲它會破壞我的實際網站

+0

http://stackoverflow.com/a/33815389/3597276 –

回答

2

刪除高度:100%;它將解決這個問題。flexbox在兒童身上應用其高度。

+0

remove align-item:center也。這裏是小提琴.. https://jsfiddle.net/mL5scvsg/1/ – rmarif

+0

,如果你想左側文本中心..那麼你需要使它也顯示:彎曲和應用align-項上它..在這裏是這個小提琴.. https://jsfiddle.net/mL5scvsg/2/ – rmarif

相關問題