码迷,mamicode.com
首页 > Web开发 > 详细

css的理解 ----footrt固定在底部

时间:2019-01-29 22:02:21      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:char   foo   --   bsp   相对   absolute   round   add   relative   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    *{
        margin:0;
        padding: 0;
    }
    html,body{
        height: 100%;
    }
    #container{

        width: 100%;
        min-height: 100%;
        padding-bottom: 50px; /*底部空出50px,放footer*/
        position: relative;
        box-sizing: border-box; /*效果:padding后不改变其宽高*/
    }
    .nav{
        /*最上面的div不能有margin-top,不然会造成整个body下移*/
        width: 100%;
        height: 50px;
        background-color: blue;
    }
    .main{

        width: 100%;
        height: 400px;
        background-color: red;
    }
    .footer{
        height:50px;
        background-color: yellow;
        position: absolute; /*相对于#container固定定位*/
        left: 0;
        bottom: 0;
        width: 100%;
    }
</style>
<body>
    <div id="container">
        <div class="nav"></div>

        <div class="main"></div>

        <div class="footer"></div>
    </div>
</body>
</html>

 

css的理解 ----footrt固定在底部

标签:char   foo   --   bsp   相对   absolute   round   add   relative   

原文地址:https://www.cnblogs.com/cl94/p/10335834.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!