在两列页面上,如何使用CSS或Javascript将左div增长到正确的div高度?

栏目: CSS · 发布时间: 7年前

内容简介:代码日志版权声明:翻译自:http://stackoverflow.com/questions/35699/on-a-two-column-page-how-can-i-grow-the-left-div-to-the-same-height-of-the-righ

我正在使用基于div的布局来制作一个两列页面(不需要表格!).问题是,我不能增加左边的div来匹配正确的高度.我的右边div通常有很多的内容.

这是我的模板的一个配对下面的例子来说明问题.

<div style="float:left; width: 150px; border: 1px solid;">
  <ul>
    <li>nav1</li>
    <li>nav2</li>
    <li>nav3</li>
    <li>nav4</li>
  </ul>
</div>
<div style="float:left; width: 250px">
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
....
</div>

alt text http://involution.com/images/divlayout.png

使用jQuery这个问题;只需在你的就绪功能中调用这个功能:
function setHeight(){
  var height = $(document).height(); //optionally, subtract some from the height
  $("#leftDiv").css("height", height + "px");
}

代码日志版权声明:

翻译自:http://stackoverflow.com/questions/35699/on-a-two-column-page-how-can-i-grow-the-left-div-to-the-same-height-of-the-righ


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Collective Intelligence实战

Collective Intelligence实战

阿拉克 / 2010-9 / 58.00元

《Collective Intelligence实战》内容简介:在互联网上,利用用户的集体智慧是成功的关键。集体智慧是一种新兴的编程技术,可让您从人们访问web和与web交互的过程中找到有价值的模式、发现这些访问者之间的关系和确定他们的个人偏好及习惯等。《collective Intelligence实战》首先介绍了集体智慧的原则和构建更具交互性网站的思想,然后通过示例开发了一个直接可用的基于Ja......一起来看看 《Collective Intelligence实战》 这本书的介绍吧!

SHA 加密
SHA 加密

SHA 加密工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具