【问题标题】:How to keep Element after animation where it is on 100% for permanently - C如何在动画后将元素永久保持在 100% 的位置 - C
【发布时间】:2018-03-24 05:49:32
【问题描述】:

我正在制作模态,其内部内容(如列表)在打开时需要从底部一一显示。我几乎做到了,但问题是我不知道如何从开始和动画之后使内容隐藏或不可见。

Here is Js Fiddle

如果有的话,请告诉我 css 中哪里有问题或建议一个方法。

代码在 Stacks 需求上是 Bellow (代码片段不采用 Bootstrap 源文件):

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">&times;</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 animation twitter-bootstrap-3 css-transitions bootstrap-modal


【解决方案1】:

试试这个代码。我已经编辑了你的 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;}
}

【讨论】:

  • 非常感谢兄弟
  • :) 你可以根据需要调整时间和变换值。
  • :) 我做到了兄弟。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多