Html 如何将两个动态大小的块并排堆叠?
如果我有两个具有动态宽度/高度的块,有没有办法在固定宽度的父元素内将它们对齐 见: 我希望蓝色/动态div始终根据红色元素的大小调整大小,并且不要位于红色下方。换句话说,蓝色方块是一个方形方块,它位于红色方块的旁边Html 如何将两个动态大小的块并排堆叠?,html,css,Html,Css,如果我有两个具有动态宽度/高度的块,有没有办法在固定宽度的父元素内将它们对齐 见: 我希望蓝色/动态div始终根据红色元素的大小调整大小,并且不要位于红色下方。换句话说,蓝色方块是一个方形方块,它位于红色方块的旁边 .wrap {width:600px; }/*static*/ .something {float:left; background:red; width:200px; height:100px;} /*dynamic width/height*/ .somethingelse {
.wrap {width:600px; }/*static*/
.something {float:left; background:red; width:200px; height:100px;} /*dynamic width/height*/
.somethingelse { background:blue;} /*dynamic width/height and should always be next to .something*/
谢谢 通过使用
display:table
和display:table cell
,您应该能够实现您想要的:
.wrap {width:600px; display:table; }/*static*/
.something {display:table-cell; background:red; width:200px; height:100px;}
.somethingelse { background:blue; display:table-cell;}