zoukankan      html  css  js  c++  java
  • html+css底部自动固定底部

    前端在切图过程中,肯定遇见过这种情况。

    页面结构由三个部分组成,头部、内容、底部。

    当一个页面的内容没撑满屏幕时,底部是跟着内容而并列存在的。

    这个时候如果是大屏的话,底部下面会有多余的空白区域,而网页设计需求必须要底部贴近浏览器底部。

    固定定位,绝度定位都不好使。

    废话不多说,直接上代码实现:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>1</title>
    <style>
    *{padding:0;margin:0;}
    html{height:100%;}
    body{min-height:100%;}
    body{position:relative;}
    .footer{
        height:100px;
        background:red;
        width:100%;
        position:absolute;
        bottom:0;
        left:0;
    }
    .box{
        padding-bottom:130px;
    }
    .box p{
        line-height:30px;
        text-align:center;
        border:solid 1px green;
    }
    </style>
    </head>
    <body>
    <div class="box">
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
        <p>离离原上草</p>
    </div>
    <div class="footer"></div>
    </body>
    </html>
  • 相关阅读:
    Java基础知识:正则表达式
    NodeJs 中 将表单数据转发到后台
    单片机的远程升级
    一些开源协议
    物联网的一些例子
    python一些开源特色库
    qt练习
    网页编程学习笔记
    PCB相关
    工业控制系统
  • 原文地址:https://www.cnblogs.com/wangjae/p/6632489.html
Copyright © 2011-2022 走看看