gpt4 book ai didi

css - Bootstrap 粘性页脚不会保持粘性

转载 作者:太空宇宙 更新时间:2023-11-03 21:43:57 24 4
gpt4 key购买 nike

我正在寻找让我的页脚变粘的建议。

我尝试使用此页面作为示例来完成此操作:Example

当页面内容小于屏幕高度时,footbar 可以正常并粘在底部,但当内容较大且出现垂直 slider 时,页脚显示在内容底部而不是粘在屏幕底部。

这是我的布局

HTML

<body>
<div class="navbar navbar-inverse navbar-fixed-top">
/* Top navbar code */
</div>

<div id="wrap">
<div class="container body-content">
@RenderBody()
<hr />
</div>
</div>

<div id="footer">
<footer>
<p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
</body>

CSS

body {
/*padding-top: 60px;
padding-bottom: 20px;*/
}

/* Set padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}

/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
max-width: 280px;
}

/* styles for validation helpers */
.field-validation-error {
color: #b94a48;
}

.field-validation-valid {
display: none;
}

input.input-validation-error {
border: 1px solid #b94a48;
}

input[type="checkbox"].input-validation-error {
border: 0 none;
}

.validation-summary-errors {
color: #b94a48;
}

.validation-summary-valid {
display: none;
}
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}

/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto;
/* Negative indent footer by its height */
margin: 0 auto -60px;
/* Pad bottom by footer height */
padding: 0 0 60px;
}

/* Set the fixed height of the footer here */
#footer {
height: 60px;
background-color: #f5f5f5;
}

最佳答案

添加:

position: fixed;
bottom:0;
width:100%;

#footer。也可以尝试使用 position:absolute

可选:您可能还想添加 text-align:center; 以保持文本居中。

这就是您所需要的。

关于css - Bootstrap 粘性页脚不会保持粘性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21696581/

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