【发布时间】:2016-12-20 18:26:46
【问题描述】:
我使用 codepen 中的这段代码制作了始终位于底部的页脚。
HTML
<div class="content">
<header>
<p>blabla</p>
</header>
<main>
<p>blaBlabla blub</p>
</main>
</div>
<footer>
<p>more bla</p>
</footer>
CSS
*{
margin: 0;
padding: 0;
border: 0;
}
html{
height: 100%;
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
body {
position: relative;
margin: 0;
padding-bottom: 250px;
min-height: 100%;
background-color: white;
}
.content {
margin: 0 auto;
width: 100%;
}
footer {
position: absolute;
right: 0;
bottom: 0;
left: 0;
background-color: black;
color: white;
text-align: center;
}
当我用“file:///C:/xampp/htdocs/folder/index.html”调用页面时它工作正常,但是当我用“http://localhost/folder/index.html”调用它时它不会。我希望有人可以帮助我,因为我真的很沮丧。
【问题讨论】:
-
可以分享一下codepen吗?
-
您可能没有为您的 css 使用相对文件路径。
-
在浏览器中打开您的 index.html 文件后 .. 单击右键并选择查看源代码 .. 在查看源代码时检查是否与 index.html 正确链接的 css 文件。