gpt4 book ai didi

html - 无法在页面底部设置页脚

转载 作者:行者123 更新时间:2023-11-28 15:54:03 26 4
gpt4 key购买 nike

我目前正在一个网站上工作,我对这个不会留在页面底部的页脚感到疯狂。我已经检查了具有相同问题的其他主题,但没有解决我的问题。

当我尝试“相对”时,页脚位于“topbox”(这是我的页眉)下方,而当我尝试“绝对”时,它位于页面中间。

 <header>
<div class="topbox">
<ul>
<li><a class="active" href="#home">Home</a></li>
<li><a href="#news">Services</a></li>
<li><a href="#contact">Clients</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</div>
</header>
<body>
<div class="wrapper">
<div class="scrollbtn"><img src="Images/Scroll.png" style="width:40%"/>
</div>
<div class="bgbox">
<div class="box2">
<a> Lorem ipsum dolor sit amet, consectetur adipiscing elit...
</a>
</div>
</div>
<div id="footer">© 2017 "TEXT" All Rights Reserved</div>
</div>
</body>

所以这里我们有 TOPBOX,它是标题,Wrapper,scrollbtn(表示需要滚动的鼠标图片),bgbox(内容的背景),box2(内容),“lorep ipsum”是内容并且很长,使用户滚动。这是我的问题,页脚在您加载时位于页面底部,因此在您向下滚动时位于页面中间。

这是 CSS:

 body, html {
width:100%;
height:100%;
background-color: #060b0f;
padding:0%;
background-image: url('../images/background3.jpg');
background-size:cover;
background-repeat: no-repeat;
background-attachment: fixed;
}
/* HEADER */
.topbox {
margin:0%;
position: fixed;
top:0%;
left: 0%;
width:100%;
z-index:999;
text-align:center;
overflow: hidden;
padding:0%;
font-family:Impact;
font-size:20px;
}
.topbox ul {
list-style-type: none;
margin: 0%;
padding: 0%;
overflow: hidden;
background-color: #459cfe;}

.topbox li {
display: inline;
}
.topbox li a {
display: inline;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.topbox li a:hover:not(.active) {
background-color: #397fcd;
}
.active {
background-color: #fff;
}
/*HEADER FIN*/
.scrollbtn {
position: absolute;
bottom : 0%;
left: 49%;
}

.hot {
color:#4080e1;
}
.box2 {
margin-top:0px;
margin-left:10%;
width : 70%;
opacity:1;
color: black;
overflow: hidden;
text-align:center;
z-index:4;

background-color:transparent;


}
.box2 a{
opacity:1;
}
.bgbox {
margin-top:0px;
margin-left:8%;
padding: 5%;
padding-left: 8%;
width : 70%;
position: absolute;
top : 10%;
left: 0%;
background-color: rgba(255,255,255,0.5);
overflow: hidden;
text-align:center;
z-index:3;


}
.bgbox:hover {
background-color: rgba(255,255,255,0.9);
}

#footer {
font-size:20px;
cursor:pointer;
color: black;
text-align: center;
width:100%;
position:relative;
left:0px;
bottom:0px;
background-color: #459cfe;
}
.wrapper {
height:100%;
}

我已经尝试了很多不同的东西(改变 body 高度,包裹所有东西,相对的,绝对的,固定的,静态的,......)我想不出别的东西。我需要一个外部的观点。

最佳答案

例子如下:

html {
height: 100%;
}

body {
position: relative;
min-height: 100%;
}

main {
padding-bottom: 30px;
}

footer {
position: absolute;
bottom: 0;
width: 100%;
height: 30px;
}
<body>
<header>
header
</header>
<main>
main
</main>
<footer>
footer
</footer>
</body>

关于html - 无法在页面底部设置页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41429564/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com