Der*_*rek 6 html css twitter-bootstrap
<div id="sidebar">sidebar</div>
<div id="content">content</div>
Run Code Online (Sandbox Code Playgroud)
侧边栏的固定宽度为100px.如何将内容宽度设置为浏览器宽度的100%?
Kev*_*her 13
你可以用简单的CSS做到这一点:
#sidebar {
float: left;
width: 100px;
}
#content {
margin-left: 100px;
}
Run Code Online (Sandbox Code Playgroud)
更新为wrapperdiv:
HTML
<div id="wrapper">
<p>wrapper</p>
<div id="sidebar">sidebar</div>
<div id="content">content</div>
<p>wrapper</p>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
* {
/* reset */
margin: 0;
padding: 0;
}
html,
body {
/* for demo purposes only */
height: 100%;
}
#wrapper {
/* for demo purposes only */
background: rgba(200, 200, 200, 0.6);
height: 100%;
}
#sidebar {
float: left;
width: 100px;
/* for demo purposes only */
background: rgba(200, 200, 200, 0.6);
height: 50%;
}
#content {
margin-left: 100px;
/* for demo purposes only */
background: rgba(200, 200, 200, 0.9);
height: 50%;
}
Run Code Online (Sandbox Code Playgroud)
工作示例:http://jsfiddle.net/kboucher/FK2tL/