将Div高度设置为屏幕的100% [英] Make Div Height 100% of Screen
本文介绍了将Div高度设置为屏幕的100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在阅读所有的100%div高度讨论,我找不到一个简单的解决方案。
I have been reading all the 100% div height discussions and I can't find a simple solution. How can I make my div take up all of the vertical height of the screen?
这是我的代码:
css
#mother {
width: 100%;
margin: 0 auto;
z-index: 1;
}
#stripe_wrap {
width: 1053px;
min-height: 500px;
margin: 0 auto;
background: lime;
}
#stripe1 {
width: 39px;
min-height: 500px;
margin: 0px 0px 0px 0px;
background: #000;
float: left;
}
#stripe2 {
width: 39px;
min-height: 500px;
margin: 0px 0px 0px 0px;
background:#000;
float: right;
}
html
<div id="mother" style="overflow-x: hidden;">
<div id="stripe_wrap">
<div id="stripe1"></div>
<div id="stripe2"></div>
</div>
</div>
推荐答案
< body> 标签的高度为100%,否则将被垂直截断以适合内容。
You have to make the <body>
tag of the height 100% as well, otherwise it is vertically truncated to fit the content.
< body>
到0px的边距,因为否则它将变为100%_of_visible_area + margin,导致垂直滚动条。
Also make sure to put the margin of <body>
to 0px, because otherwise it will become 100%_of_visible_area + margin, resulting in a vertical scroll bar.
这篇关于将Div高度设置为屏幕的100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文