过去两天我一直在打破这个问题。基本上,我正在创建一个页面布局,其中第一个块占据屏幕的宽度和高度,第二个块需要是相对的。
示例:http://www.shegy.nazwa.pl/themeforest/exit/normal/
<body>
<div id = "block1">
This is block 1 taking 100% width and height of screen.
</div>
<div id="block2">
Block 2 is relative to block 1
</div>
</body>
答案 0 :(得分:1)
诀窍是将height: 100%;
和margin: 0;
添加到body / html中。然后它创造了奇迹:)。
<div id="box1">HELLO HELLO THIS IS RED BOX, ARE YOU HEARING ME BLUE?</div>
<div id="box2">YES, RED, I'VE GOT YOU LOUD AND CLEAR. OVER. <div>
html, body {
height: 100%;
margin: 0;
}
#box1 {
min-height: 100%;
min-width: 100%;
color: white;
background-color: red;
}
#box2 {
min-height: 100%;
min-width: 100%;
color: white;
background-color: blue;
}