方法一享器哈班其础件事是架考发求关通互面待需了:全局增加一个负值下边距等于底是能览调不页新代些事几求事都时学下是事功过部高度
html, body {
height: 100%;
margin: 0;
}
.content {
padding: 20px;
min-height: 100%;
margin: 0 auto -50px;
}
.footer,.push {
height: 50px;
}
Sticky Footer with Negative Margin 1
Add Content
Footer
方法二我自址哈这工边识框处己按后大都加控不架的:底部元素增加比抖朋要插支一圈不者地器享说几负值上边距
html, body {
height: 100%;
margin: 0;
}
.content {
min-height: 100%;
}
.content-inside {
padding: 20px;
padding-bottom: 50px;
}
.footer {
height: 50px;
margin-top: -50px;
}
body {
font: 16px Sans-Serif;
}
h1 {
margin: 0 0 20px 0;
}
p {
margin: 20px 0 0 0;
}
footer {
background: #42A5F5;
color: white;
line-height: 50px;
padding: 0 20px;
}
Sticky Footer with Negative Margin 2
Add Content
Footer
方法三:使朋不功事做时次功好来多这开制的请一例农在用calc()计算内容的高是能览调不页新代些事几求事都时学下是事度
.content {
min-height: calc(100vh - 70px);
padding: 40px 40px 0 40px;
}
.footer {
height: 50px;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font: 16px Sans-Serif;
}
h1 {
margin: 0 0 20px 0;
}
p {
margin: 0 0 20px 0;
}
footer {
background: #42A5F5;
color: white;
line-height: 50px;
padding: 0 20px;
}
Sticky Footer with calc()
Add Content
Footer
方法四:使用flexbo新直能分支调二浏页器朋代说x
html {
height: 100%;
}
body {
min-height: 100%;
display: flex;
flex-direction: column;
}
.content {
flex: 1;
padding: 20px;
}
.footer {
padding: 20px;
}
Sticky Footer with Flexbox
Add Content
Footer
方法五:使用遇新是直朋能到分览支体调grid布局
html {
height: 100%;
}
body {
min-height: 100%;
display: grid;
grid-template-rows: 1fr auto;
}
.content {
padding: 20px;
}
.footer {
grid-row-start: 2;
grid-row-end: 3;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font: 16px Sans-Serif;
}
h1 {
margin: 0 0 20px 0;
}
p {
margin: 0 0 20px 0;
}
.footer {
background: #42A5F5;
color: white;
padding: 20px;
}
Sticky Footer with Grid
Add Content
Footer