sticky footer布局,定位底部footer

news/2024/5/19 4:27:19

其作用就是当内容区域比较少时,让footer也能正常定位到底部,以前我们使用js来达到这种效果,其实用css也是完全可以的

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>sticky footer</title>
  <style type="text/css">
  /* 第一步设置盒子为满屏大小 */
    .box{
      position: fixed;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      overflow: auto;
      background: green;
    }
    /* 第二步子盒子设置最小高度且清除浮动 */
    .box .main{
      width: 100%;
      min-height: 100%;
    }
    .box .main .content{
      background: orange;
    }
    /* 第三步footer的高度和margin-top要相等 */
    .box .footer{
      position: relative;
      width: 100%;
      height: 100px;
      background: #f3f3f3;
      margin: -100px auto 0 auto;
      clear: both;
      text-align: center;
    }
    .clearfix{
      display: inline-block;

    }
    .clearfix::after{
      content: ".";
      display: block;
      height: 0;
      line-height: 0;
      visibility: hidden;
      clear: both;
    }
  </style>
</head>
<body>
  <div class="box">
    <div class="main clearfix">
      <div class="content">
        <p>这里是内容区域</p>
        <p>这里是内容区域</p>
        <p>这里是内容区域</p>
      </div>
    </div>

    <div class="footer">这是footer区域</div>
  </div>
</body>
</html>

原理我不清楚,效果很完美


http://www.niftyadmin.cn/n/1748392.html

相关文章

制作一个简单的文件系统

三.制作一个简单的文件系统 0 BusyBox简介 什么是Busybox呢&#xff1f; 从名字上直接理解&#xff0c;Busybox是一个“繁忙的盒子”&#xff0c;其实&#xff0c;Busybox可以理解为一个Linux的命令集合&#xff0c;我们在进行Linux操作时所需要的常用命令&#xff0c;都…

linux 6.x crontab 定时任务使用

2019独角兽企业重金招聘Python工程师标准>>> 安装crontab&#xff1a; yum install crontabs 服务操作说明&#xff1a; /sbin/service crond start //启动服务/sbin/service crond stop //关闭服务/sbin/service crond restart //重启服务/sbin/service crond relo…

u-boot启动过程分析

从源代码看系统启动过程 为什么要分析源代码&#xff1f;分析优秀的源代码本身就是一个学习的过程&#xff0c;也是进行深入研究的必经之路。不过在此我们的主要目的并非要研究U-boot或Bootloader技术本身&#xff0c;而仅仅是为了成功的并且恰当的将U-Boot移植到我们的开发板…

数据库学习笔记-20170309

数据库语言&#xff1a;DDL(Data Defination Language):数据定义语言&#xff0c;主要用于定义数据库、表、视图、索引和触发器等。像DROP/CREATE/ALTER.DML(Data Manipulation Language):主要包括对数据的增删改查。INSERT插入数据、UPDATE更新数据、DELETE删除数据。DQL(Data…

container_of

container_of 理解 收藏 问题&#xff1a;如何通过结构中的某个变量获取结构本身的指针&#xff1f;&#xff1f;&#xff1f; 关于container_of见kernel.h中:/*** container_of - cast a member of a structure out to the containing structure* ptr: the pointer to t…

android SoundPool

SoundPool主要用于播放时间较短的音效&#xff0c;使用soundPool占用的资源也不会太大。 参考链接 http://o7planning.org/en/10523/playing-sound-effects-in-android-with-soundpool http://www.cnblogs.com/plokmju/p/android_SoundPool.html Example 创建一个按键&#xff…

嵌入式系统终端分析

嵌入式系统终端分析 ------------------------------------本文系本站原创,欢迎转载! 转载请注明出处:http://sjj0412.cublog.cn/------------------------------------------ 当我们打开机器或一个嵌入式系统时&#xff0c;我们可能都适应了它会显示信息&#xff0c;我们也…

什么是 jQuery EasyUI

jQuery EasyUI 是一个基于 jQuery 的框架&#xff0c;集成了各种用户界面插件。 jQuery EasyUI 框架提供了创建网页所需的一切&#xff0c;帮助您轻松建立站点。 easyui 是一个基于 jQuery 的框架&#xff0c;集成了各种用户界面插件。easyui 提供建立现代化的具有交互性的 jav…