gpt4 book ai didi

html - float 时DIV高度问题

转载 作者:可可西里 更新时间:2023-11-01 14:58:24 26 4
gpt4 key购买 nike

您好,我在考虑 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com