我試圖創造一些這樣的: https://tympanus.net/Development/FullscreenLayoutPageTransitions/動態創建具有絕對的位置,這可以擴展到整個屏幕的div
但我面臨的問題是,我的div是動態的 - 可以是任意數量的來自xhr服務電話。我試圖疊加div,但點擊後,它們不會從它們的位置增長到佔據整個屏幕,而是從左上角這樣增長:
https://codepen.io/anon/pen/vJPNOq。
如何獲得與第一個鏈接相同的效果,即動態列表的計數可能未知?
<div>
<h1>Your dashboard</h1>
<span class="close">X</span>
<section class="parent">
<section>room1</section>
<section>room2</section>
<section>room3</section>
<section>room4</section>
<section>room5</section>
<sectoin>room6</sectoin>
</section>
</div>
section section{
width:150px;
height:150px;
background-color:green;
margin:10px;
padding:30px;
transition:all .5s linear;
}
.parent{
position:relative;
height:100%;
width:100%;
background-color:red;
}
.expanded{
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
z-index:999;
background-color:red;
}
.close{
position:absolute;
top:100;
right:0;
z-index:1000;
cursor:pointer;
}
$('.parent section').click(function(){
$(this).addClass('expanded');
})
$('.close').click(function(){
$('.parent section').each(function(){
$(this).removeClass('expanded');
})
})
加入'寬度:50%'和'浮動:left'到'節段{}'可能工作 – adiga
你不需要JQ或JS這種效果。它可以完全由CSS來完成。 – Redu
你能展示如何爲動態div做些什麼? –