我有一個居中的容器div,目前有3個其他divs裏面。它們都有框陰影(結果添加了大約5px的邊距)。100%寬度的div與箱子陰影ovelaps父div
我遇到的問題是第一個div(即將發佈)是100%寬度,並且在右側(overflow: hidden
已設置)被截斷。或者它溢出它包含div一點。這樣可以,但下面的其他2個div浮動並排,因此不會溢出一點(如果size設置爲比可用空間更大,則最近的div會在最後移動)。
填充沒有幫助。除了將寬度設置爲98%之外,還有其他解決方案嗎?
下面是我使用的CSS:
.mainSection{
width:1020px;
margin:70px auto 0px auto;
}
.widget{
background-color:rgba(255, 255, 255, 0.5);
-webkit-box-shadow:0 0 5px 2px #CCC;
-moz-box-shadow:0 0 5px 2px #CCC;
box-shadow:0 0 5px 2px #CCC;
border:1px solid #CCC;
margin:4px;
overflow:hidden;
}
/* 3 child divs */
.widget.upcoming{
float:left;
width:100%;
height:380px;
}
.widget.recent{
float:right;
width:260px;
height:auto;
}
.widget.latest{
float:left;
width:740px;
height:460px;
}
<section class="mainSection">
<article class="widget upcoming">
<header>
<h3>Upcoming</h3>
</header>
</article>
<article class="widget news">
<article>
<p>Some text</p>
</article>
</article>
<article class="widget latest">
<header>
<h3>Latest</h3>
</header>
</article>
<aside class="widget recent">
<header>
<h3>Recent</h3>
</header>
</aside>
</section>
請發表html。 –
是的請html,我試圖幫助,如果更多的信息將是真棒http://jsbin.com/uharax/1/ –
添加HTML,請參閱編輯。 – DominicM