可能重复: div高度
你好,
我有一个DIV,我想要的高度是基于浏览器-100 of的可视区域。有什么方法可以让我做到这一点,使DIV高度被正确地设置在第一位,然后调整如果用户进入并调整浏览器大小。我想这将涉及javascript。
谢谢,
发布于 2011-06-02 07:26:40
CSS唯一解决方案:
.foo {
position: absolute;
left: 50px;
top: 50px;
right: 50px;
bottom: 50px;
background-color: lime;
}
这里的演示
发布于 2011-06-02 07:21:37
网络用jQuery改变DIV的高/宽随体宽/高的变化上有一篇文章
<script language=”javascript”>
$(document).ready(function(){
var height1 = $(document).height(); // height of full document
var height2 = $(“#header”).height(); // height of header
var height_diff = height1 – height2 + “px”;
document.getElementById(‘test’).style.height = height_diff; // Set the remaining height in test DIV.
});
</script>
其中test
是div
的id。
https://stackoverflow.com/questions/6211235
复制相似问题