【发布时间】:2016-03-30 09:30:26
【问题描述】:
我在尝试使用 CSS 将网站页脚置于底部时遇到问题。我尝试了几种在互联网上找到的方法来解决这个问题,但都没有奏效。我试图用相对位置打开一个div 并使用绝对定位将我的页脚放在其中,尽管它再次不起作用。这是我的代码,
body {
background-color: white;
width: 100%;
height: 100%;
margin: auto;
position: absolute;
font-size: 20px;
}
header {
background-color: #292627;
width: 100%;
height: 40%;
font-size: 2vmin;
color: white;
padding: 1%;
position: relative;
}
#logo {
height: 50%;
}
aside {
position: relative;
background-color: yellow;
width: 20%;
font-size: 3vmin;
margin: 0%;
padding: 1%;
float: left;
}
article {
position: relative;
float: right;
width: 75%;
padding: 1%;
font-size: 3vmin;
}
footer {
width: 100%;
height: 10%;
position: relative;
bottom: 0%;
padding: 1%;
background-color: black;
color: white;
}
#copyright {
bottom: 0%;
text-align: center;
font-size: 3vmin;
color: red;
}
<!DOCTYPE html>
<html>
<head>
<title> AUFA projects</title>
<script src = "script.js"></script>
<link rel="stylesheet" type = "text/css" href = "stylesheet_home.css">
</head>
<body>
<header>
<a href="http://aufaprojects.ml"> <img src="recources/aufa_proj.png" alt="AUFAprojects" id="logo"></a>
<h1>AUFA Projects</h1>
</header>
<aside>
<p>What you are looking for is Viewport Percentage Units: http://dev.w3.org/csswg/css-values/#viewport-relative-lengths
The values are: ‘vw’ (viewport width), ‘vh’ (viewport height), ‘vmin’ (the smaller of vw or vh), ‘vmax’ (the larger or vw or vh).
1 v == 1% of the initial containing block
using it looks like this:
p {font-size: 4vw;}
As you can see, when the viewport widt</p>
</aside>
<article>
<h1> About us </h1>
<p>AUFA is a group of AUA students, who post their project, programs and other data in this website. You are allowed to use the content or modify it, however you should give credits in the following form
"The original code was created by AUFA (aufaprojects.ml)"</p>
</article>
<footer>
<p id = "copyright"> Copyright © AUFA</p>
</footer>
</body>
</html>
请帮助解决我的问题, 提前致谢。
【问题讨论】:
-
页脚位置应该是absolote,body relative也应该abulote body标签下的其他标签
-
为什么不使用固定位置?您是要将其放置在视口窗口底部还是网页底部
-
@devpro 具有绝对定位,它仅适用于固定屏幕。滚动时它停留在同一个地方
-
@Adjit 我不想使用固定定位,而是想将页脚放在网页底部
-
是的@adjit 是正确的位置固定或改变我的建议
标签: html css positioning footer