可变大小的浮动 div

发布于 2024-12-17 16:10:33 字数 158 浏览 1 评论 0原文

我有 3 个 div 都向左浮动。我想将第二个 div 和第三个 div 设置为特定大小(基于像素或百分比),而第一个 div 仅占用其余空间。

此外,在运行时,根据用户的权限,可能不会显示特定大小的 div 之一。我需要第一个 div 来占据剩余的空间。

我该怎么做?

I have 3 divs all floated left. 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.

Additionally at runtime depending on the user's privileges one of the specific sized divs might not be displayed. I need the first div to take up the space left over.

How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

或十年 2024-12-24 16:10:33

您可以使用 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/

它在 IE7 和 IE7 中不起作用。以下。

但检查一下它是否适用于所有浏览器:

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

You can use display:table property for like :

.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/

It's not work in IE7 & below.

But check this it's work in all browsers:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文