当前位置: 首页 > news >正文

小猿圈网站页面底部固定的方法

网络发展到了今天,很多朋友对于网站已经不陌生了,但是当我们看网页时你注意到网站的底部了吗?虽然很少人会注意到他,但是如果不在底部的话,会很难看,今天小猿圈web前端讲师就为你介绍网站页面底部固定的方法。


方法一:footer高度固定+绝对定位

html

<div class="dui-container">

<header>Header</header>

<main>Content</main>

<footer>Footer</footer>

</div>

css

.dui-container{

position: relative;

min-height: 100%;

}

main {

padding-bottom: 100px;

}

header, footer{

line-height: 100px;

height: 100px;

}

footer{

width: 100%;

position: absolute;

bottom: 0

}

方法二:在主体content上的下边距增加一个负值等于底部高度

html

<header>Header</header>

<main>Content</main>

<footer>Footer</footer>

css

html, body {

height: 100%;

}

main {

min-height: 100%;

padding-top: 100px;

padding-bottom: 100px;

margin-top: -100px;

margin-bottom: -100px;

}

header, footer{

line-height: 100px;

height: 100px;

}

方法三:将页脚的margin-top设为负数

html

<header>Header</header>

<main>Content</main>

<footer>Footer</footer>

css

main {

min-height: 100%;

padding-top: 100px;

padding-bottom: 100px;

}

header, footer{

line-height: 100px;

height: 100px;

}

header{

margin-bottom: -100px;

}

footer{

margin-top: -100px;

}

方法四: 通过设置flex,将footer的margin-top设置为auto

html

<header>Header</header>

<main>Content</main>

<footer>Footer</footer>

css

body{

display: flex;

min-height: 100vh;

flex-direction: column;

}

header,footer{

line-height: 100px;

height: 100px;

}

footer{

margin-top: auto;

}

方法五: 通过函数calc()计算内容的高度

html

<header>Header</header>

<main>Content</main>

<footer>Footer</footer>

css

main{

min-height: calc(100vh - 200px); /* 这个200px是header和footer的高度 */

}

header,footer{

height: 100px;

line-height: 100px;

}

方法六: 通过设置flexbox,将主体main设置为flex

html

<header>Header</header>

<main>Content</main>

<footer>Footer</footer>

css

body{

display: flex;

min-height: 100vh;

flex-direction: column;

}

main{

flex: 1

}

小猿圈提醒大家合理利用自己每一分每一秒的时间来学习提升自己,不要再用"没有时间“来掩饰自己思想上的懒惰!趁年轻,使劲拼,给未来的自己一个交代!想学习IT编程类知识的可以到小猿圈网站去自学前端,里面有最新最全的视频以及专业的解答。


转载于:https://juejin.im/post/5cd13d4851882535bb0bd2d7

相关文章:

  • mysqlclient操作MySQL关系型数据库
  • Loadrunner报Failed to connect to server 127.0.0.1
  • poj1284(欧拉函数+原根)
  • 应用中有使用到集群么?多大规模?
  • Azure RIS的工作原理以及其与AWS RIs的比较
  • 使用DB业务拆分解决写压力大问题
  • JS中的值比较操作:==,===,Object.is()
  • 解决*.props打开失败问题
  • selector在手机上或浏览器显示各种姿势(虚拟下拉菜单)
  • 使用benchmarkSQL测试数据库的TPCC
  • 8.C(内存管理)
  • 产品上线后,出现BUG的处理流程
  • Greenplum修改GPCC的密码
  • 2019第十一周编程总结
  • 设计模式--Singleton_(1)(C#版)
  • 《Java8实战》-第四章读书笔记(引入流Stream)
  • 345-反转字符串中的元音字母
  • angular2开源库收集
  • Docker容器管理
  • emacs初体验
  • express如何解决request entity too large问题
  • Spring Cloud(3) - 服务治理: Spring Cloud Eureka
  • spring security oauth2 password授权模式
  • Spring思维导图,让Spring不再难懂(mvc篇)
  • vue--为什么data属性必须是一个函数
  • 从重复到重用
  • 设计模式(12)迭代器模式(讲解+应用)
  • 腾讯优测优分享 | 你是否体验过Android手机插入耳机后仍外放的尴尬?
  • 正则与JS中的正则
  • 资深实践篇 | 基于Kubernetes 1.61的Kubernetes Scheduler 调度详解 ...
  • ​软考-高级-信息系统项目管理师教程 第四版【第19章-配置与变更管理-思维导图】​
  • # Swust 12th acm 邀请赛# [ A ] A+B problem [题解]
  • # 透过事物看本质的能力怎么培养?
  • #pragam once 和 #ifndef 预编译头
  • #我与Java虚拟机的故事#连载04:一本让自己没面子的书
  • #在线报价接单​再坚持一下 明天是真的周六.出现货 实单来谈
  • (04)Hive的相关概念——order by 、sort by、distribute by 、cluster by
  • (ZT)一个美国文科博士的YardLife
  • (九十四)函数和二维数组
  • (论文阅读26/100)Weakly-supervised learning with convolutional neural networks
  • (一)Java算法:二分查找
  • (一)使用Mybatis实现在student数据库中插入一个学生信息
  • (原創) 是否该学PetShop将Model和BLL分开? (.NET) (N-Tier) (PetShop) (OO)
  • (转)AS3正则:元子符,元序列,标志,数量表达符
  • (转)Scala的“=”符号简介
  • .NET 3.0 Framework已经被添加到WindowUpdate
  • .NET Core IdentityServer4实战-开篇介绍与规划
  • .NET Framework 服务实现监控可观测性最佳实践
  • .NET Micro Framework初体验(二)
  • .NET/ASP.NETMVC 大型站点架构设计—迁移Model元数据设置项(自定义元数据提供程序)...
  • .NET/C# 将一个命令行参数字符串转换为命令行参数数组 args
  • .netcore 6.0/7.0项目迁移至.netcore 8.0 注意事项
  • .sdf和.msp文件读取
  • @data注解_一枚 架构师 也不会用的Lombok注解,相见恨晚
  • [<死锁专题>]