【发布时间】:2017-01-30 09:18:16
【问题描述】:
我正在尝试使用 Bootstrap Grid 制作一个侧边栏,但我希望它一直延伸到底部。 Image of what I am trying to accomplish.
我不想破坏响应能力并尽可能避免使用 Javascript 解决方案。
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<style>
/* Footer CSS */
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #3e8f3e;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-10" style="background-color: #f5e79e">
Column that does not need to stretch
</div>
<div class="col-md-2" style="background-color: #ffff00;">
Sidebar/column to stretch down to the bottom (to the footer)
</div>
</div>
</div>
<footer class="footer">
<div class="container-fluid">
<h5>Footer to reach down too</h5>
</div>
</footer>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
代码也可以在jsfiddle.net 上使用,这可能会更容易使用。 确保您拖动结果,以便该站点不会显示移动版本,其中列在彼此下方。
感谢任何帮助,因为我多年来一直被这个问题困扰。
【问题讨论】:
-
@RayKoren 我没有否决你的答案。
-
你的侧边栏是导航菜单吗?
-
@Zacy5000 我有两个选择:jsfiddle.net/grvpanchal/1k1wdu8u 和 jsfiddle.net/grvpanchal/g6kxjxuo
-
嘿,你有没有尝试在侧边栏类中添加“height:100vh”?它就像一个魅力,让我知道这是否有帮助!
-
@GerardoSabetta 其实你的建议很有帮助。我不知道 vh 并设法使用 CSS 的 calc 函数来阻止滚动条发生。
标签: javascript jquery html css twitter-bootstrap