简体   繁体   English

可变大小的div浮动

[英]Variable sized floating divs

I have 3 divs all floated left. 我有3个div都向左浮动。 I want to set the second div and third div to specific sizes (based on pixels or percentages) and the first div to simply take up the rest of the space. 我想将第二个div和第三个div设置为特定的大小(基于像素或百分比),而第一个div仅仅占用其余空间。

Additionally at runtime depending on the user's privileges one of the specific sized divs might not be displayed. 此外,在运行时,根据用户的权限,可能不会显示特定大小的div之一。 I need the first div to take up the space left over. 我需要第一个div来占用剩余的空间。

How can I do this? 我怎样才能做到这一点?

You can use display:table property for like : 您可以使用display:table属性,例如:

.parent{
    width:100%;
    display:table;
}
.fill{
    border: 3px solid green;
    display:table-cell;
}
.fixed{
    width: 100px;
    border: 3px solid blue;
    display:table-cell;
}

http://jsfiddle.net/WVDNe/8/ http://jsfiddle.net/WVDNe/8/

It's not work in IE7 & below. 在IE7及以下版本中不起作用。

But check this it's work in all browsers: 但是,请检查它是否适用于所有浏览器:

http://jsfiddle.net/LJGWY/3/ http://jsfiddle.net/LJGWY/3/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM