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/

相关文章:

html - 如何将 HTML 页面嵌入到 outlook 和 gmail 电子邮件正文中?

css - Bootstrap 选项卡 : Background image inside tag not streching to 100%

html - 如何用 Firefox 修复 <div> 的宽度?

css - 如何在剪辑的 div 中正确定位图像列表

css - div没有内容?

javascript - 我想创建一个 js 文件并且必须动态加载 img 标签

javascript - 如果我用 DOM 中的另一个元素替换某个元素,是否必须清理该元素?

java - MySQL 尝试更新 MySql 表的语法,但语法已关闭

javascript - DIV 内的居中图像未给出预期位置

css - Angular Material 2 mat-slide-toggle 改变拇指的滑动距离