Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html CSS一个接一个的定位_Html_Css - Fatal编程技术网

Html CSS一个接一个的定位

Html CSS一个接一个的定位,html,css,Html,Css,我有两个divs。第一个应该适合加载后的页面。滚动后,下一个应位于第一个下方。如何做到这一点 这是我的密码: <div class="first"> </div> .first { position: absolute; top: 0; right: 0; bottom: 0; left: 0; } .first{位置:绝对;顶部:0;右侧:0;底部:0;左侧:0;} 及 .second{} 它们应该具有哪些附加属性?试试这个 body,html {

我有两个
div
s。第一个应该适合加载后的页面。滚动后,下一个应位于第一个下方。如何做到这一点

这是我的密码:

<div class="first">

</div>

.first { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }


.first{位置:绝对;顶部:0;右侧:0;底部:0;左侧:0;}


.second{}
它们应该具有哪些附加属性?

试试这个

body,html {
    height:100%;
}
.first {
    min-height:100%;
    background:#f00;
}
.second {
    background:#ff0;
    height:200px;
}

将第一个div的宽度和高度设置为100%

但是,这些div之间有一个空间。我一点也不知道如何删除它。

“位置:绝对;顶部:0;右侧:0;底部:0;左侧:0;”将使其宽度达到100%。但是,由于绝对定位,它会出现在另一层的顶部。绝对定位意味着结果是固定的。你需要一些相关的东西才能得到你想要的。我应该提到的。使用固定位置。
body,html {
    height:100%;
}
.first {
    min-height:100%;
    background:#f00;
}
.second {
    background:#ff0;
    height:200px;
}