gpt4 book ai didi

html - 将子 DIV 移到父 DIV 之外

转载 作者:搜寻专家 更新时间:2023-10-31 21:49:42 26 4
gpt4 key购买 nike

我就直奔主题吧。我有一个宽度为 100% 的子 div,它位于具有固定宽度的包装器下。我想知道如何让子 div“突破”并具有 100% 全屏页面宽度。代码是这样的,我尝试使用相对/绝对定位但没有成功。

<div class="wrapper">
...Some other code...
<div class="banners">
<div class="first"><img src="http://placehold.it/200x200"></div>
<div class="second"><img src="http://placehold.it/200x200"></div>
</div>
...Some other code...
</div>

fiddle 可以在这里找到http://jsfiddle.net/qMYQw/

除了“横幅”div 之外,该 div 的上方和下方还有几个部分,这就是“横幅”在包装器中的原因

P.S 在标题 DIV 的上方/下方还有其他部分,所以简单地设置 position:absolute 并不能解决问题

最佳答案

Fiddle

.banners img {  
width:100%;
}

.banners .first, .banners .second {
float:left;
width:50%;
position: absolute;
left:0;
border:1px solid blue;
}

.banners .second {
margin-left: 50%;
}

关于html - 将子 DIV 移到父 DIV 之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24927910/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com