简单的 HTML / CSS 问题 - 高度和高度屏幕分辨率
我需要使 div 具有一定的高度,它里面有一个重复的图像,我希望它占据整个屏幕,无论用户的屏幕分辨率是多少。自动高度取决于内容,所以我需要使用 javascript 来实现我的目标吗?或者我可以使用带有“clear:both;”的东西吗?它的属性以便始终将 div 拉伸到底部?我真的很想避免使用 JavaScript。
I need to make a div have a certain height, it has a repeating image in it and I want it to take up the entire screen no matter what the users screen resolution is. Height auto depends on the content so do I need to use javascript in order to achieve my goal? Or can I use something with a "clear:both;" property on it in order to always stretch the div to the bottom? I would really like to avoid javascript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只要父容器(如
body
或html
)具有100% 高度
,那么div
也应该。例如: http://jsfiddle.net/jasongennaro/Jm8Mt/
当然,您的
div
将有一个class
...示例仅供展示As long as the parent container (like
body
orhtml
) has100% height
, then thediv
should also. SoExample: http://jsfiddle.net/jasongennaro/Jm8Mt/
Of course, your
div
would have aclass
... example was just for show给 div 100% 的高度和宽度将使其占据整个窗口。
Giving the div 100% height and width will make it take up the entire of the window.