Mal*_*xxl 1 html css positioning
我有一个主要的div有100%的宽度,并有2个div.一个有200px宽度,其他将是100%-200px,我的意思是;
-----------------this is main div -------------
| |
| ----subdiv1---- -------------subdiv2----------|
|| | | ||
| -------------- ---------------------------- |
|-----------------------------------------------|
Run Code Online (Sandbox Code Playgroud)
subdiv1有200 px,subdiv2的宽度将是其余的空白空间.我搜索谷歌但无法找到.
这是一个可能的解决方案,我使用float: left最左边的div的margin-left规则,以及正确的div 的规则:http://jsfiddle.net/P4xMj/
示例HTML:
<div id="container">
<div id="left">
Some content here
</div>
<div id="right">
Some more content goes over here on the right. Let's make this
content really long to see what happens when we wrap more than
one or two line's worth. Extra text to fill the void.
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
示例CSS(背景颜色仅用于可见性):
#container {
background: #FF0;
overflow: auto;
padding: 10px;
}
#left {
background: #0F0;
float: left;
width: 200px;
}
#right {
background: #F00;
margin-left: 210px;
}
Run Code Online (Sandbox Code Playgroud)