【发布时间】:2014-03-15 08:41:57
【问题描述】:
这个问题似乎有很多已解决的问题,但它们似乎都不适合我......
我创建了这个小 jsfiddle 给你看:jsfiddle footer
还有 CSS:
.footer {
width:798px;
border-top: 2px solid #2E181A;
clear: both;
padding: 5px 0 0 0;
background-color: inherit;
text-align: center;
bottom:0;
background-color: #E6D9BD;
position:relative;
height: 30px;
margin: -30px auto 2px auto;
z-index:30;
}
.container {
width: 788px;
margin: 0px auto 0px auto;
padding: 0px 0px 30px 0px;
border:5px solid #2E181A;
background-color: #E6D9BD;
min-height: 100%;
position:relative;
content: " "; /* 1 */
display: table; /* 2 */
}
.contentleft {
background-color: inherit;
margin:5px 10px 10px 10px;
padding:10px 5px 30px 5px;
float:left;
overflow: hidden;
width: 300px;
display:block;
}
.contentright {
background-color: inherit;
margin:5px 0px 10px 10px;
border:0px solid #2E181A;
padding:10px 5px 30px 5px;
float:left;
overflow: hidden;
width: 420px;
display:block;
}
我在div.footer 中设置了一个上边框,这应该是可见的,并且边框和div.container 之间有一点空间。
希望你能快速浏览一下代码,看看我做错了什么!
【问题讨论】:
-
根据定义,粘性页脚不会在用户滚动期间附着在页面上吗?假设这是真的,那么为什么你有
position的.footer相对而不是固定的? -
嗯...我可能对“粘性”的定义理解错了。我的意思是一个页脚,不管内容有多长,它都会停留在底部。我的页脚这样做了,但不是我想要的......
-
@Nit,谢谢链接,但这是我很久以前关注的,但不知何故弄乱了我的 css,现在我完全失去了这个大图......
-
@SimonJensen 你希望它是什么样子?