[英]Make element fill the width of its container AND not have margins push it out of that container?
[英]How Can I Have Div Placed Outside a Container with Auto Margins and Have it Fill the Rest of the Browser Width?
我在JSFiddle上有一個簡單的測試布局。 http://jsfiddle.net/jJuMH/我希望#outside div跨越瀏覽器的寬度直至容器,僅在容器的右側。 我已經嘗試過浮動,但是這使容器移位,並且絕對定位也不起作用。
#full{
width:100%;
height: 300px;
background-color:#0CF
}
#container{
width:75%;
position:relative;
height:300px;
background-color:#FF9900;
margin:0 auto;
}
#oustide {
width:100%;
height:50px;
float:right;
background-color:#66FF66
}
<div id="full">
<div id="oustide"></div>
<div id="container"></div>
</div>
對我來說也真的沒有意義..但是為什么不僅僅使用流體塊來構建您的布局呢?
.left, .middle, .right {
float: left;
min-height: 250px;
}
.left {
width: 20%;
background-color: red;
}
.middle {
width: 60%;
background-color: green;
}
.right {
width: 20%;
background-color: blue;
}
小提琴: http : //jsfiddle.net/jJuMH/1/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.