调整粘性页脚以适应长文本
Adjusting Sticky Footer to long Texts
我正在尝试创建粘性页脚。找了个例子here 调整了一下
但是,它似乎无法适应长文本。当内容足够长,以至于出现滚动条时,内容就在页脚下方流动,而不是一直停留在上方。
JS:
function myFunction() {
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
CSS:
footer div {
display: inline-block;
vertical-align: top;
right: 50%;
padding: 10px;
}
footer {
position: absolute;
left: 0;
right: 0;
bottom: 0;
width: 100%;
min-height: 30px;
line-height: 30px;
vertical-align: middle;
background-color: #1A1A1A;
color: #a9a9a9;
border-top: 8px solid #2F2F2F;
padding: 10px 40px 20px;
font-size: 0.7em;
overflow: hidden;
}
您必须将绝对位置更改为:
position:fixed;
bottom:0;
这里是fiddle
我正在尝试创建粘性页脚。找了个例子here 调整了一下
但是,它似乎无法适应长文本。当内容足够长,以至于出现滚动条时,内容就在页脚下方流动,而不是一直停留在上方。
JS:
function myFunction() {
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
CSS:
footer div {
display: inline-block;
vertical-align: top;
right: 50%;
padding: 10px;
}
footer {
position: absolute;
left: 0;
right: 0;
bottom: 0;
width: 100%;
min-height: 30px;
line-height: 30px;
vertical-align: middle;
background-color: #1A1A1A;
color: #a9a9a9;
border-top: 8px solid #2F2F2F;
padding: 10px 40px 20px;
font-size: 0.7em;
overflow: hidden;
}
您必须将绝对位置更改为:
position:fixed;
bottom:0;
这里是fiddle