【发布时间】:2013-01-30 08:51:09
【问题描述】:
我正在尝试弄清楚如何使用 HTML(5) 和 Twitter Bootstrap 构建这样的布局:
它不需要在 IE
我一直在尝试修改 this、this 和 this 之类的示例/相似之处,但没有运气。
您知道我可以找到这样的布局的任何示例吗,或者您知道如何制作吗?任何帮助将不胜感激!
【问题讨论】:
标签: jquery html twitter-bootstrap
我正在尝试弄清楚如何使用 HTML(5) 和 Twitter Bootstrap 构建这样的布局:
它不需要在 IE
我一直在尝试修改 this、this 和 this 之类的示例/相似之处,但没有运气。
您知道我可以找到这样的布局的任何示例吗,或者您知道如何制作吗?任何帮助将不胜感激!
【问题讨论】:
标签: jquery html twitter-bootstrap
这可能有效:
HTML
<div id="wrapper">
<div id="left-column"></div>
<div id="right-column"></div>
</div>
<div id="footer">
</div>
CSS
body, html {height:100%; padding:0; margin:0;}
#wrapper {height:100%; padding:0 0 60px 260px; box-sizing:border-box; -moz-box-sizing:border-box;}
#left-column {width:260px; margin-left:-260px; float:left; height:100%; background-color:red; overflow-y:scroll;}
#right-column {width:100%; float:left; height:100%; background-color:blue; overflow-y:scroll;}
#footer {height:60px; position:fixed; bottom:0; left:0; width:100%; background-color:green;}
目前它已将溢出-y 设置为滚动,但您可能希望使用 jquery 添加他,因此它并不总是在 chrome 等浏览器中添加滚动条,我不确定它是否与 Twitter 引导程序兼容
这个版本在内容太大时增加了溢出:
【讨论】:
以下是一个简单的示例,但应该可以满足您的要求。
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
/* Don't include the * reset just for demonstration purposes only */
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
#sidebar {
background: green;
height: 100%;
position: absolute;
left: -260px;
top: 0;
width: 260px;
}
#container {
background: blue;
margin: 0 0 0 260px;
min-height: 100%;
position: relative;
}
#footer {
background: red;
height: 60px;
position: fixed;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<div id="container">
<div id="sidebar">
sidebar
</div>
container
</div>
<div id="footer">
I am a footer
</div>
</body>
</html>
【讨论】:
#content div 中添加一些填充,则可以解决此问题。这是一个小提琴jsfiddle.net/R67wg/8,这里有更多关于折叠边距w3.org/TR/CSS2/box.html#collapsing-margins
对于页脚,您是否考虑过使用引导导航栏?您可以使用navbar-fixed-bottom 类将其固定到底部。它将始终可见。
<div class="navbar navbar-fixed-bottom">
<div class="navbar-inner">
<ul class="nav">
<li><a href="#">footer</a></li>
</ul>
</div>
</div>
由于您使用的是引导程序,因此您应该考虑左侧 div 的 Affix 菜单选项。这将允许您在滚动时将菜单保留在屏幕上。
【讨论】: