我正在制作模态,其内部内容(如列表)在打开时需要从底部逐个显示。我设法几乎做到了,但问题是我不知道如何使内容从开始和动画之后隐藏或不可见。
这是 Js 小提琴
如果有的话,请让我知道 CSS 中的混乱在哪里或建议一种方法。
代码在堆栈需求时是波纹管(代码段不采用引导源文件):
li { transition: transform 1s, opacity 1s; animation-name: list-live; animation-duration: 3s; animation-iteration-count:1; }
li:first-child { animation-delay:100ms; }
li:nth-child(2) { animation-delay:300ms;}
li:nth-child(3) { animation-delay:500ms;}
li:nth-child(4) { transition: transform 1s, opacity 4s; animation-delay: 700ms; }
@keyframes list-live {
0% { transform: translate(0, 200px); opacity: 0;}
100% { transform: translate(0, 0); opacity:1;}
}
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<ul>
<li class="tr1">Item 1</li>
<li class="tr2">Item 2</li>
<li class="tr3">Item 3</li>
<li class="tr4">Item 4</li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
试试这段代码。我已经编辑了你的 css 代码。
li {
transition: all .5s;
animation:list-live linear 2s forwards;
opacity: 0;
}
.modal-content {
overflow: hidden;
}
li:first-child { animation-delay:100ms; }
li:nth-child(2) { animation-delay:300ms;}
li:nth-child(3) { animation-delay:500ms;}
li:nth-child(4) { animation-delay: 700ms; }
@keyframes list-live {
0% { transform: translateY(200px); opacity: 0;}
100% { transform: translateY(0); opacity:1;}
}