【发布时间】:2011-12-02 07:48:40
【问题描述】:
研究了一整天的柔性盒子模型,我必须说我真的很喜欢它。它以一种快速而干净的方式实现了我在 JavaScript 中实现的功能。然而有一件事让我很烦恼:
我无法扩展 div 以获取由柔性盒模型计算的完整尺寸!!!
为了说明这一点,我将举一个例子。其中两个灵活的地方采用精确的 with 和高度,但其中的 div 仅采用 "<p>...</p>" 元素的高度。对于这个例子,没关系,但我最初尝试的是在另一个“灵活的盒子模型”中放置一个“灵活的盒子模型”,我认为这必须是可能的
html, body {
font-family: Helvetica, Arial, sans-serif;
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
#box-1 {
background-color: #E8B15B;
}
#box-2 {
background-color: #C1D652;
}
#main {
width: 100%;
height: 100%;
overflow-x: auto;
overflow-y: hidden;
}
.flexbox {
display:-moz-box;
display:-webkit-box;
display: box;
text-align: left;
overflow: auto;
}
H1 {
width: auto;
}
#box-1 {
height: auto;
-moz-box-orient: vertical;
-webkit-box-orient: vertical;
box-orient: vertical;
-moz-box-flex: 3;
-webkit-box-flex: 3;
box-flex: 3;
}
#box-2 {
height: auto;
min-width: 50px;
-moz-box-orient: vertical;
-webkit-box-orient: vertical;
box-orient: vertical;
-moz-box-flex: 1;
-webkit-box-flex: 1;
box-flex: 1;
}
#fullsize{
background-color: red;
height: 100%;
}
<div id="main" class="flexbox">
<div id="box-1" class="flexbox">
<div id="fullsize">
<p>Hallo welt</p>
</div>
</div>
<div id="box-2" class="flexbox">
</div>
</div>
【问题讨论】:
标签: html