我对此感到头痛,我一直在搜索,但无法找到解决方法。
因此,当我从另一个html文件更改DIV的内容时,我正在尝试自动化DIV的高度,因此它将匹配其他html文件的高度。
这是简化的html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
function p01(){
document.getElementById("change").innerHTML='<object type="text/html" data="01.html" ></object>';
}
</script>
<script>
function p02(){
document.getElementById("change").innerHTML='<object type="text/html" data="02.html" ></object>';
}
</script>
</head>
<body>
<div class="sidebar1">
<ul class="nav">
<li onclick="p01()"><a href="#">1</a></li>
<li onclick="p02()"><a href="#">2</a></li>
</ul>
</div>
<div style="width:75%; height:100%" id="change"></div>
</body>
</html>
答案 0 :(得分:0)
尝试使用:
.sidebar1
{
height:auto;
}
希望它会对你有所帮助。 问候。
答案 1 :(得分:0)
you can set the min height as well as height:auto,
so that you can set a particulate height to the container, and when the data in the container will get full it will take the auto height
class name{
min-height:768px;
height:auto;
}
check the jsfiddle for more understanding [jsfiddle][1]
答案 2 :(得分:0)
检查屏幕截图中的检查区域并更新高度:值