如何将div高度设置为用户显示器分辨率的100%? [英] How to set div height to 100% of user's monitor resolution?
本文介绍了如何将div高度设置为用户显示器分辨率的100%?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
height:100%
在CSS显然不工作。所以有什么其他CSS或JavaScript / jQuery解决方案这个问题吗?请指教。
height: 100%
in CSS obviously doesn't work. So is there any other CSS or JavaScript/jQuery solutions to this problem? Please advise.
推荐答案
假设您的问题元素是< div>
。如果你确保你的< div>
的高度有参考,几乎所有的问题都会消失:
'Let's say your problem element is a <div>
. If you make sure your <div>
s height has something to reference to, almost all your problems will disappear:
#my_div
{
height: 100%; /* Won't work. What is 100% of an unknown/unset value? */
}
确保< div& / code>的父母也有一个设定的高度。我通常这样做(好吧,不完全是,但你得到的想法):
Make sure the <div>
's parents have a set height too. I usually do this (well, not exactly, but you get the idea):
#my_div, #parent_of_the_div, body, html
{
height: 100%; /* This works, but it will show scrollbars if the body
or html elements have padding or margins. */
}
这篇关于如何将div高度设置为用户显示器分辨率的100%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文