2014-01-24 109 views
2
最大的高度

我的问题是基于 css: set the height of floating divs as maximum of their heights - Is it possible to fix this jsFiddle with pure css so that all 3 divs that are in the same row have the same height, the maximum of their 3 heitghts?CSS:设定浮动的div的高度与利润率

的解决方案是here - jsFiddle

但是,我没有提到我需要一些元素之间的边距(因为不重要和容易添加)。因此,建议使用display:table-cell解决方案。不幸的是,保证金财产不适用于display:table-cell元素。

是否仍然有可能解决我的问题之间的空间之间的一些空间纯css? 原始代码在这里,我想所有三个div的高度是相同的,他们之间有一些空间,比如说3px

的代码是在这里:

<style> 
#main{ 
    border:1px solid red; 
    width:605px; 
    overflow:hidden; 
} 
#zero{ 
    border:1px solid blue; 
} 
.small{ 
    border:1px solid green; 
    float:left; 
    width:199px; 
} 
</style> 
<div id="main"> 
    <div id="zero"> 
     0 
    </div> 
    <div class="small"> 
     small text 
    </div> 
    <div class="small"> 
     large text large textlarge textlarge textlarge textlarge textlarge textlarge textlarge textlarge textlarge textlarge textlarge text 
    </div> 
    <div class="small"> 
     another small text 
    </div> 
</div> 

这里是原来的问题@jsFiddle

再次,如果可能的话,我宁愿选择一个纯粹的css解决方案

+0

这可能有助于:http://stackoverflow.com/questions/18346083/space-between-divs-display-table-cell –

+0

但是,如果你考虑使用JS的任何机会:http://stackoverflow.com/a/18362090/1725764 –

回答

0

您可以在#main上使用border-spacing: 3px;

JsFiddle

+0

谢谢!这是解决方案(适用于我的情况)! – Haradzieniec

0

你好我的队友打了一下你的代码,如果您删除浮动离开,并添加display:table-cell;你得到你想要的结果。

至于divs之间的差距不能确定它是否可能与一个div类。

小提琴:

http://jsfiddle.net/7A95U/1/

比尔。