【问题标题】:Equal Column Heights等柱高
【发布时间】:2010-06-09 21:45:31
【问题描述】:

我希望东、西 div 向下延伸以匹配中心 div 的高度...可以吗?

非常感谢。

.con{
padding-left: 22px;
padding-right: 22px;
overflow: hidden;
}

.col{
position: relative;
float: left;
}

.west{
width: 7px;
right: 22px; 
margin-left: -100%;
background: url(http://www.example.com/west.png) repeat-y;
padding: 0 0 0 15;
}

.east{
width: 7px;
margin-right: -22px;
background: url(http://www.example.com/east.png) repeat-y;
padding: 0 15 0 0;
}

.center{
width: 100%;
}


<div class="con">
  <div class="center col">
   Test Text<br/>
   Test Text<br/>
   Test Text<br/>
   Test Text<br/>
  </div>
  <div class="west col">
 </div>
 <div class="east col">
 </div>
</div>

【问题讨论】:

标签: html css


【解决方案1】:

您可以从这里为纯 CSS 所做的事情开始: HTML/CSS: Making two floating divs the same height

或者使用 JavaScript 布局。

【讨论】:

    【解决方案2】:

    我使用了这个 jQuery 解决方案,效果很好……

    var maxHeight = 0;
    $(".col").each(function(){
      maxHeight = $(this).height() > maxHeight ? $(this).height() : maxHeight;
    }).height(maxHeight);​
    

    仅供参考。尝试对它进行 CSS 处理。

    【讨论】:

      猜你喜欢
      • 2018-10-23
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      • 2011-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-15
      相关资源
      最近更新 更多