html - 如何使用 HTML 和 CSS 在页面底部制作 2 个固定页脚?
问题描述
我这里有一个 html 页面,我想在页面下方制作 2 个页脚。但我的问题是第二个页脚与第一个页脚合并。有人可以告诉我解决方案吗?
这是我的页脚的代码:
#footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #787a7c;
color: white;
padding: 0px 0px 18px 0px;
}
.footerLinks a {
text-decoration: none;
color: #f2f2f2;
font-size: 10px;
font-family: Malgun Gothic;
}
.footerLinks a:hover {
text-decoration: underline;
}
.lowerFooter {
background-color: orange;
}
.footerLinks {
float: left;
position: relative;
}
<div class="contextSize">
<div id="footer">
<div class="upperFooter content">
<nav class="footerLinks">
<a href="#">개인정보처리방침
</a> |
<a href="#">이메일무단수집거부
</a> |
<a href="#">사이트맵</a> |
<a href="#">찾아오시는 길</a>
</nav>
<h6 class="account">ADMIN
<h6>
</div>
<div class="lowerFooter content">
sample
</div>
</div>
</div>
编译时,两个页脚相互合并。
解决方案
它们不会相互合并。尝试为它们中的每一个应用背景,以便您可以看到它。您为周围元素设置背景,但不为上部页脚设置背景。看这里:
/*CSS code snippet*/
#footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: red; /* changed */
color: white;
padding: 0px 0px 18px 0px;
}
.footerLinks a {
text-decoration: none;
color: #f2f2f2;
font-size: 10px;
font-family: Malgun Gothic;
}
.footerLinks a:hover {
text-decoration: underline;
}
.lowerFooter {
background-color: orange;
}
.footerLinks {
float: left;
position: relative;
}
/* added: */
.upperFooter {
background: green;
}
.upperFooter, .lowerFooter {
padding: 10px;
margin: 0;
}
<!-- HTML Code Snippet-->
<div class="contextSize">
<div id="footer">
<div class="upperFooter content">
<nav class="footerLinks">
<a href="#">개인정보처리방침
</a> |
<a href="#">이메일무단수집거부
</a> |
<a href="#">사이트맵</a> |
<a href="#">찾아오시는 길</a>
</nav>
<h6 class="account">ADMIN</h6>
</div>
<div class="lowerFooter content">
sample
</div>
</div>
</div>
另一个提示:你的结尾</h6>
也没有 / 。
推荐阅读
- c++ - int64_t 不包含 13 位整数
- python - 使用其他模块对 main.py 进行单元测试
- html - 为什么这个下降器显示在 Safari 中的另一个字符下方?
- c# - 如何在 WPF 应用程序中使用 SystemMediaTransportControls?
- javascript - 未捕获的 SyntaxError:JSON 中的意外令牌'
- php - 如何使用 Timber\Post 从 ACF 扩展 WP post 对象数组
- ruby-on-rails - 使用 Foreman 设置 rails 环境
- mysql - 使用 phpMyAdmin 从 MySQL 导出数据不再流式传输
- swift - 如何在 XCode 和 Swift 中创建和重用模块?
- amazon-web-services - AWS 快照如何持久化?