首页 > 其他 > 详细

粘连布局

时间:2020-02-09 20:52:19      阅读:61      评论:0      收藏:0      [点我收藏+]

经典粘连布局:有一块内容

,当
的高度足够长的时候,
应该紧跟在
元素的后面;当
元素比较短的时候(比如小于屏幕的高度),我们期望
能够粘连在屏幕底部
移动端可以添加如下meta标签:<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">,以解决字体过小的问题

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <title>Title</title>
    <link rel="stylesheet" href="font/style.css">
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        html, body {
            height: 100%;
        }

        #wrap {
            min-height: 100%;
            background-color: aliceblue;
        }

        #wrap .main {
            padding-bottom: 50px;
        }

        #footer {
            height: 50px;
            background-color: dodgerblue;
            text-align: center;
            line-height: 50px;
            margin-top: -50px;
        }
    </style>
</head>
<body>
<div id="wrap">
    <div class="main">
        main <br>
        main <br>
        main <br>
        main <br>
        main <br>
        main <br>
    </div>
</div>
<div id="footer">
    footer
</div>
</body>
</html>

粘连布局

原文:https://www.cnblogs.com/kanaliya/p/12288508.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!