<html>
<script>
window.onload=function(){
alert("screen height:" + screen.height);
}
</script>
<style>
.abc{height:expression(screen.height); background-color:red;}
</style>
<body>
<div class="abc">xxx</div>
</body>
</html>
<script>
window.onload=function(){
alert("screen height:" + screen.height);
}
</script>
<style>
.abc{height:expression(screen.height); background-color:red;}
</style>
<body>
<div class="abc">xxx</div>
</body>
</html>
本文介绍了一种使用HTML和JavaScript结合的方式来自适应地获取并显示用户的屏幕高度。通过在网页加载完成时触发JavaScript函数获取屏幕高度,并利用CSS设置了一个高度等同于屏幕高度的红色div元素。
1万+

被折叠的 条评论
为什么被折叠?



