html - CSS 拉伸(stretch)元素

标签 html css

我有如下的html

<div>
   <div class="left">
   </div>
   <div class="center">
   </div>
   <div class="right">
   </div>
</div>


.left
{
  background: none repeat scroll 0 0 white;
  border-right: 1px solid #C3C3C3;
  float: left;
  margin-top: 30px;
  min-height: 100%;
  position: absolute;
  width: 170px;
}

.center
{
  background: none repeat scroll 0 0 white;
  float: left;
  margin-left: 171px;
  margin-top: 30px;
  min-height: 100%;
  position: absolute;
  width:895px;
}

.right
{
  background: none repeat scroll 0 0 #DEDFE8;
  border-left: 5px solid #BDC1DE;
  float: right;
  margin-top: 30px;
  min-height: 100%;
  position: absolute;
  width: 276px;
}

当中心面板拉伸(stretch)时,左右面板保持在 100% 的高度

有没有办法在中心面板拉伸(stretch)时拉伸(stretch)左右面板。

编辑

当中心面板包含使中心 div 扩展超过 100% 的最小高度的 html 控件时,左右面板不会扩展,并且这些面板具有不同的颜色和边框,并且页面看起来不正确当左右面板不展开而中间面板展开时,可以看到间隙。

最佳答案

我个人喜欢 www.ejeliot.com 的等高栏

http://jsfiddle.net/spacebeers/s8uLG/3/

您将容器设置为 overflow hidden ,然后在每个 div 上添加负边距底部和相等的正填充底部。

#container { overflow: hidden; }
#container div { float: left; background: #ccc; width: 200px; margin-bottom: -2000px; padding-bottom: 2000px; }
#container .col2 { background: #eee; }

<div id="container">
   <div>
        <p>Content 1</p>
   </div>
   <div class="col2">
        <p>Content 2</p>
        <p>Content 2</p>
        <p>Content 2</p>
        <p>Content 2</p>
   </div>
</div>

Faux Columns 也不错,而且可能更容易设置,但如果您真的反对使用图像,这是一个非常好的方法。

关于html - CSS 拉伸(stretch)元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8407031/

相关文章:

Javascript 使动画变慢?

javascript - 我想在我的div中添加onload ='startGame()'

javascript - jquery调整文件高度

javascript - 使用 Ajax 单击按钮删除表行

html - 多列列表中的高度差

css - 将链接/按钮与包含其他元素的容器的右侧和底部对齐 - 不能使用 flex

html - 使用 HTML5 的背景图片以适应页面

css - 字体在 Chrome 中呈现不佳

html - padding-top 不影响 Chrome

Javascript获取所有状态下元素的样式