在两列页面上,如何使用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


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

查看所有标签

猜你喜欢:

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

The Haskell School of Expression

The Haskell School of Expression

Paul Hudak / Cambridge University Press / 2000-01 / USD 95.00

Functional programming is a style of programming that emphasizes the use of functions (in contrast to object-oriented programming, which emphasizes the use of objects). It has become popular in recen......一起来看看 《The Haskell School of Expression》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

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

HSV CMYK互换工具