gpt4 book ai didi

html - 页眉和页脚不随正文滚动

转载 作者:行者123 更新时间:2023-11-28 17:35:37 28 4
gpt4 key购买 nike

我有一个正在处理的网页。当前,页眉和页脚保留在页面上。唯一滚动的部分是 body 。滚动条只出现在页面的正文部分。我想弄清楚如何更改它,以便整个页面滚动,而不是只有一个部分,其余部分被锁定到位。我试过从我的 css 中删除“position: fixed”,但是除了从屏幕上完全删除页脚之外,这并没有改变任何东西。

这是我的CSS

/********************************
* Shared Layout *
********************************/
#header {
padding: 5px 0px 0px 20px;
top: 0;
position: fixed;
height: 170px;
background-color: #000;
}

.logo-image {
float: left;
margin: 7px 20px 0px 0px;
}

.clear-fix:after {
content: ".";
clear: both;
display: block;
height: 0;
visibility: hidden;
}

body {
background-color:#efeeef;
color: #333;
font-size: .85em;
font-family: "Segoe UI", Verdana, Helvetica, Sans-Serif;
margin: 0;
padding: 0;
overflow: hidden;
}

#body {
top: 170px; bottom: 130px;
background-color: #efeeef;
clear: both;
padding-bottom: 0px;
overflow-y: auto;
position: absolute;
}

.content-wrapper {
margin: 0 auto;
max-width: 1125px;
}

#footer {
position: fixed;
bottom: 0;
clear: both;
background-color: #000;
font-size: .8em;
height: 130px;
color: #FFF;

}

#footer, #body, #header {
left: 0; right: 0;
}

#follow-icons {
padding-top: 13px;
float: right;
}

#logo-table {
clear: left;
margin: 0 auto;
}

#logo-table td{
padding: 0px 10px;
}

.float-left {
float: left;
}

.float-right {
float: right;
}

这是HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Atlas Web Pages</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
<script src="@Url.Content("~/Scripts/knockout-2.1.0.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.7.1.js")" type="text/javascript"></script>
</head>
<body style="-webkit-box-shadow:3px 2px 15px #3D3D3D">
<header id="header">
<div class="web-header">
<div class="logo-image">
<img style="vertical-align:top" src="~/Images/WebPageLogo.png" height="85" width="820" alt="Atlas Logo" />
<br />
<div style="color:#FFF">*A southpaw's approach to bowling*</div>
</div>
<div class="float-right">
<nav>
<ul id="menu">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("The Team", "About", "About")</li>
<li>@Html.ActionLink("Current Line-Up", "CurrentList", "Current")</li>
<li>@Html.ActionLink("Retired Equipment", "RetiredList", "Retired")</li>
<li>@Html.ActionLink("Tournaments", "TourneyInfo", "Tournament")</li>
<li>@Html.ActionLink("Bowling Videos", "Videos", "Video")</li>
<li>@Html.ActionLink("Sponsors", "Sponsors", "Sponsor")</li>
</ul>
</nav>
</div>
</div>
</header>
<div id="body">
@RenderSection("featured", required: false)
<section class="content-wrapper main-content clear-fix">

@RenderBody()
</section>
</div>
<footer>
<div id="footer">
<div class="content-wrapper">
<div class="float-left">
<p>&copy; @DateTime.Now.Year: Southpaw Web Solutions&trade; - Email: jmilam90@gmail.com</p>
</div>
<div id="follow-icons">
<a href ="www.facebook.com/jmilam90"><img src="~/Images/FBIcon.png" alt="Follow on Facebook" height="40" width="40" /></a>
<a href ="www.twitter.com/jmilam900"><img src="~/Images/TwitIcon.png" alt="Follow on twitter" height="40" width="40" /></a>
<a href ="https://www.youtube.com/channel/UCCSdkWipauQ1mhzEPAJfOnA"><img src="~/Images/YTIcon.png" alt="Subscribe on Youtube" height="40" width="40" /></a>
</div>
</div>
<table id="logo-table">
<tr>
<td>
<img src="~/Images/Logos/MBW.png" width="99" height="60" alt="McCorveys Bowling World Logo" />
</td>
<td>
<img src="~/Images/Logos/EboniteLogo.png" width="93" height="60" alt="Ebonite Logo" />
</td>
<td>
<img src="~/Images/Logos/TrackLogo.png" width="152" height="60" alt="Track Bowling Logo" />
</td>
<td>
<img src="~/Images/Logos/HammerLogo.png" width="100" height="60" alt="Hammer Bowling Logo" />
</td>
<td>
<img src="~/Images/Logos/ColumbiaLogo.png" width="123" height="60" alt="Columbia 300 Logo" />
</td>
<td>
<img src="~/Images/Logos/PBALogo.png" width="60" height="60" alt="PBA Logo" />
</td>
</tr>
</table>
</div>
</footer>
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
</html>

谁能告诉我需要删除/更改哪些内容才能让整个页面滚动?

最佳答案

在没有看到 HTML 的情况下,您似乎需要:

  1. 删除 position: fixed; #header#footer 以及现在多余的 topbottom

  2. 问题也是top: 170px;引起的bottom: 130px;#body 上的 position: absolute。完全删除 #body

  3. 删除现在多余的:

#footer, #body, #header {
left: 0; right: 0;
}

你还剩下:

#header {
height:170px;
background-color:#000
}

.logo-image {
float:left;
margin:7px 20px 0 0
}

.clear-fix:after {
content:".";
clear:both;
display:block;
height:0;
visibility:hidden
}

body {
background-color:#efeeef;
color:#333;
font-size:.85em;
font-family:"Segoe UI",Verdana,Helvetica,Sans-Serif;
margin:0;
padding:0;
overflow:hidden
}

.content-wrapper {
margin:0 auto;
max-width:1125px
}

#footer {
clear:both;
background-color:#000;
font-size:.8em;
height:130px;
color:#FFF
}

#follow-icons {
padding-top:13px;
float:right
}

#logo-table {
clear:left;
margin:0 auto
}

#logo-table td {
padding:0 10px
}

.float-left {
float:left
}

.float-right {
float:right
}

关于html - 页眉和页脚不随正文滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25126111/

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