分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

CSS 实现footer置底

发布时间:2023-09-06 01:46责任编辑:林大明关键词:CSS

1.将内容部分的margin-bottom设置为负数

<style type="text/css">*{padding:0;margin:0;}html,body{height:100%;}.wrapper{ ???min-height:100%; ???margin-bottom:-50px;/* 等于footer的高度 */}.footer, .push{ ???height: 50px; ???background:red;}</style></head><body><div class="wrapper"> ???<div class="push"></div></div><div class="footer">footer</div></body>

2. 将页脚的margin-top设置为负数

<style type="text/css">*{padding:0;margin:0;}html,body{height:100%;}.content{ ???min-height:100%;}.content-inside{ ???padding:20px; ???padding-bottom:50px; ???background:blue;}.footer{ ???height: 50px; ???background:red; ???margin-top:-50px;}</style></head><body><div class="content"> ???<div class="content-inside"></div></div><div class="footer">footer</div></body>

3.使用calc设置内容高度

<style type="text/css">*{padding:0;margin:0;}html,body{height:100%;}.content{ ???height: calc(100% - 50px);}.footer{ ???background:red; ???height: 50px;}</style></head><body><div class="content"></div><div class="footer">footer</div></body>

4.使用flex弹性布局

CSS 实现footer置底

原文地址:https://www.cnblogs.com/fjl-vxee/p/8641092.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved