我正在尝试研究如何使用 Twitter bootstrap 3 制作非常简单的布局。
它基本上是一个粘性页眉(始终位于视口(viewport)顶部),一个位于内容底部的页脚(不固定在视口(viewport)底部),然后是两 3 列之间。左侧和右侧的宽度固定 (200px),中间的列根据屏幕宽度变化。
我已经尝试了太多方法来做到这一点,我开始有点失去情节。 有人可以帮帮我吗。
编辑 1(5):我的页眉页脚布局代码。我尝试了太多不同的东西来尝试实现这三列。编辑另一次尝试。这里的问题是 a) 列是流动的,b) 12 列布局在左侧并且没有占据整个宽度。
<div class="container-full">
<div class="navbar navbar-static-top">
<div class="navbar-inner blue-bg">
<a href="#" class="brand"><img src="images/kab/logo-header.png" alt="KAB Logo Large"/></a>
</div>
</div>
<div class="container-full">
<div class="row-fluid">
<div class="span1">
<h4>Left Column</h4>
</div>
<div class="span10">
<h4>Center Content</h4>
</div>
<div class="span1">
<h4>Right Column</h4>
</div>
</div>
</div>
<div class="navbar navbar-fixed-bottom">
<div class="navbar-inner blue-bg" style="height: 77px;"> </div>
</div>
</div>
编辑 2:添加了一个糟糕的尝试,尝试使用 DIV,但这不会破坏使用框架的目标吗?
编辑 3:理想布局的结构
+------------------------------------------------------+
| Header |
+------------+------------------------------+----------+
| | | |
| | | |
| Fixed | Fluid Column | Fixed |
| 200px | | 200px |
| | | |
| | | |
| | | |
| | | |
| | | |
+------------+------------------------------+----------+
| Footer |
+------------------------------------------------------+
编辑 4:这是我在这里找到的一个 fiddle ,并已对其进行了调整以适应,但右侧有一些空白。此外,这是实现此类布局的最佳做法吗?
最佳答案
如果有人仍在使用 BS3,并且想知道如何获得此设计,这就是解决方案:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
<style>
/*
This for the 200px.
Put as comments cause it's breaking the view to 3 nested divs on many small-screen divices.
.col-xs-2 {min-width: 200px;}
*/
</style>
<div class="container-fluid text-center">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">Header</div>
</nav>
<div class="row" style="margin-top: 50px;">
<div class="col-xs-2">
<h4>Left Column</h4>
</div>
<div class="col-xs-8">
<h4>Center Content</h4>
</div>
<div class="col-xs-2">
<h4>Right Column</h4>
</div>
</div>
<div class="col-12">
<div class="container">Footer</div>
</div>
</div>
关于html - 推特 Bootstrap 。 3 列带页眉和页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20924697/