伸展div来填充身体

one*_*eat 11 html css layout

<html style="margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;">
    <body style="height:100%;width:100%;">
        <div style="height:20px;background-color:red;"></div>
        <div style="background-color:black;"></div>
        <div style="height:20px;background-color:blue;"></div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

如何让第二个div伸展以填充剩余空间(放置第一个和第三个div后)?

Joh*_*wis 12

如果你想要粘贴页脚系统,那么使用这种技术:

* {
    margin: 0;
}

html, body {
    height: 100%;
}

.wrapper {
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin: 0 auto -20px;
}

.footer, .push {
    height: 20px;
}
Run Code Online (Sandbox Code Playgroud)

http://ryanfait.com/resources/footer-stick-to-bottom-of-page/


thi*_*dot 5

如果我正确了解您的意图(谁知道..):

现场演示编辑

HTML:

<div id="top"></div>
<div id="mid"></div>
<div id="bot"></div>
Run Code Online (Sandbox Code Playgroud)

CSS:

html, body {
    margin: 0;
    padding: 0;
    border: 0;
}
body {
    color: #fff
}

#top, #mid, #bot {
    position: absolute;
    width: 100%
}

#top {
    height: 20px;
    background: red;

    top: 0;
}
#mid {
    background: #000;

    top: 20px;
    bottom: 20px
}
#bot {
    height: 20px;
    background: blue;

    bottom: 0
}
Run Code Online (Sandbox Code Playgroud)