Last active
April 21, 2019 03:50
-
-
Save xyeig/0f07e3adc8fb614c93818ab1e884563c to your computer and use it in GitHub Desktop.
css 元素出现动画
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <button onclick="add()">添加</button> | |
| <ul class="list" id="list"> | |
| <li>box</li> | |
| </ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function add(){ | |
| var child = document.createElement('li'); | |
| child.innerText = 'box'; | |
| document.getElementById('list').appendChild(child); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .list{ | |
| list-style: none; | |
| width: 200px; | |
| color: #fff; | |
| counter-reset: num; | |
| } | |
| .list li{ | |
| padding: 10px; | |
| margin: 10px; | |
| background:slateblue; | |
| animation:show .5s; | |
| } | |
| .list li:after{ | |
| counter-increment: num; | |
| content: counter(num) | |
| } | |
| .list li:nth-child(2n + 1) { | |
| background: tomato | |
| } | |
| .list li:nth-child(3n + 2) { | |
| background:royalblue | |
| } | |
| .list li:nth-child(5n + 3) { | |
| background:violet | |
| } | |
| .list li:nth-child(7n + 4) { | |
| background:tan; | |
| color: #000; | |
| } | |
| .list li:nth-child(11n + 5) { | |
| background:yellowgreen | |
| } | |
| @keyframes show{ | |
| from { | |
| opacity: 0; | |
| transform: translateX(100px) | |
| } | |
| to { | |
| opacity: 1; | |
| transform: translateX(0) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment