html - float 时DIV高度问题

标签 html

您好,我在考虑 float div 时遇到了一个问题,我无法弄清楚。我知道很多人遇到了同样的问题,但我还没有找到正常的解决方案。也许你能帮我? 我希望当右边的 div 增长它的高度时,左边的 div 会增长它的高度。右边的会动态增长,因为里面的文字或其他东西会有不同的大小。

这是代码:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">


<style>

#content
{
 width:600px;
 height:auto;
 overflow:hidden;
 background-color:#FF3399;
}

#content1
{
 width:300px;
 background-color:#3333CC;
 float:left;
}

#content2
{
 width:300px;
 overflow:hidden;
 background-color:#CCFF66;
}


</style>


</head>

<body>

<div id="content">

    <div id="content1">

    1

    </div>

    <div id="content2">
    2
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>

    </div>

</div>



</body>
</html> 

最佳答案

这是永恒的 css 列高度问题。 There are some (painful) ways to work around it使用纯 css,但我很高兴使用这个 jQuery 插件:http://www.cssnewbie.com/equalheights-jquery-plugin/

这不是处理它的“正确”方式,但根据我的经验,这是唯一不会让你发疯的方式。

关于html - float 时DIV高度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3186216/

相关文章:

javascript - 我无法使用 jQuery 和 php 更改数据库中的单词

html - 使用 SMARTY 截断 HTML 格式的文本

html - 使用 wkhtmltopdf : span issue 将 Twitter Bootstrap 页面转换为 PDF

javascript - js - 跟踪容器没有子元素的时刻

html - 单击父元素时防止 contenteditable 元素获得焦点

html - 带有标题和副标题的语义导航链接

javascript - 另一个图像 slider JQuery 问题

javascript - 如何从表单中选择输入并将其存储在变量中?

javascript - Image or Div behind Div (HTML web development)

javascript - 将回车键聚焦到特定按钮