我试图创造一些这样的: 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做些什么? –