因为项目需要设置div的高度在不同的浏览器尺寸上都显示良好,用height:auto是无效的,所以需要用js来解决,
于是设置这个div的id为bannerbig,并用js调用修改、自动改
//auto adapt clients height for banner which i rename it div id = "bannerbig"
function refreshSize(){
var totolHeight = document.documentElement.clientHeight;
var height = totolHeight - 70;
console.log(totolHeight + ' - ' + height);
document.getElementById('bannerbig').style.height = height+'px';
};
refreshSize();
window.onresize = refreshSize;
</script>
JS自适应高度设置
本文介绍了一种使用JavaScript实现div元素高度自适应浏览器窗口大小的方法。通过监听窗口大小变化并调整指定div(ID:bannerbig)的高度,确保其在不同分辨率下均能保持良好的视觉效果。
509

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



