所以基本上這背後的概念是假的效果具有旗幟定位絕對有它背後的空div正確的,模擬它的位置:
的HTML
<div class="container">
<div class="content"><p>potatopotatopotatopotatopotatopotatopotatopotato</p></div>
<div class="content">potatopotatopotatopotatopotatopotatopotatopotatopotatopotato</div>
<div class="banner">banner</div>
<div class="filler">filler</div>
<div class="content">potatopotatopotatopotatopotatopotato</div>
<div class="content">potatopotatopotatopotatopotato</div>
</div>
The Css
.container{
width:960px;
height:1000px;
margin:0 auto;
}
.content{
height:200px;
border:1px solid #000;
}
.banner{
position:absolute;
width:100%;
height:20px;
border:1px solid red;
left:0;
-webkit-transition:all 0.2s linear;
}
.filler{
height:20px;
-webkit-transition:all 0.2s linear;
}
.toggled{
height:100px;
}
And 的JS:
$('.banner').on('click', function(){
$('.filler, .banner').toggleClass('toggled');
});
Fiddle
位置是絕對,添加一個「填充物」,在它的位置,相同高度的DIV,當你切換手風琴切換填充div的高度,以及 – 2014-10-09 16:49:32
我很困惑。你的JSfiddle是否已經完成你所描述的內容?您想要的狀態的一些草圖可能會有所幫助。另外,我不確定我看到你的問題是什麼。 – 2014-10-09 16:52:06
@SurrealDreams他希望橫幅跨越100%的窗口,但它必須位於960像素的容器中。 – 2014-10-09 16:52:48