【发布时间】:2017-09-03 22:15:22
【问题描述】:
我正在尝试创建这样的东西: https://tympanus.net/Development/FullscreenLayoutPageTransitions/
但我面临的问题是我的 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');
})
})
【问题讨论】:
-
将
width: 50%和float:left添加到section section {}可能会起作用 -
这个效果不需要 jQ 或 JS。它可以简单地由 CSS 完成。
-
你能说明如何为动态 div 做到这一点吗?
-
您是否尝试将 position: absolute 更改为 position: fixed 以用于扩展类。
-
是的。它没有工作
标签: javascript jquery css css-animations