一款基于css3的列表toggle特效实例好代码教程

在岁月中跋涉,每个人都有自己的故事,看淡心境才会秀丽,看开心情才会明媚。累时歇一歇,随清风漫舞,烦时静一静,与花草凝眸,急时缓一缓,和自己微笑。

  今天给大家带来一款基于css3的列表toggle特效。右上角一个按钮,当列表不显示的时候,单击按钮列表动画出现,当列表显示时,单击按钮,列表动画消失,效果图如下:

  实现的代码。

  htm代码:

复制内容到剪贴板
  1. <divclass='menu'>
  2. togglevisibility</div>
  3. <ulclass='listreverse'>
  4. <liclass='item'>Item1</li>
  5. <liclass='item'>Item2</li>
  6. <liclass='item'>Item3</li>
  7. <liclass='item'>Item4</li>
  8. <liclass='item'>Item5</li>
  9. <liclass='item'>Item6</li>
  10. <liclass='item'>Item7</li>
  11. <liclass='item'>Item8</li>
  12. <liclass='item'>Item9</li>
  13. <liclass='item'>Item10</li>
  14. <liclass='item'>Item11</li>
  15. <liclass='item'>Item12</li>
  16. </ul>

  css3代码:

CSS Code复制内容到剪贴板
  1. *{
  2. -moz-box-sizing:border-box;
  3. box-sizing:border-box;
  4. }
  5. body{
  6. margin:0;
  7. padding:0;
  8. font-family:'AvenirNext';
  9. background:#000;
  10. color:white;
  11. }
  12. .menu{
  13. background:tomato;
  14. padding:20px;
  15. position:absolute;
  16. z-index:1;
  17. height:55px;
  18. top:0;
  19. rightright:50px;
  20. }
  21. .list{
  22. -webkit-perspective:100vw;
  23. perspective:100vw;
  24. width:100vw;
  25. height:100vh;
  26. display:-webkit-flex;
  27. display:-ms-flexbox;
  28. display:flex;
  29. -webkit-flex-flow:columnwrap;
  30. -ms-flex-flow:columnwrap;
  31. flex-flow:columnwrap;
  32. }
  33. .list.hidden{
  34. pointer-events:none;
  35. }
  36. .list.hidden.item{
  37. -webkit-animation:disappearboth;
  38. animation:disappearboth;
  39. -webkit-animation-direction:alternate;
  40. animation-direction:alternate;
  41. }
  42. .list.reverse{
  43. -webkit-flex-flow:row-reversewrap-reverse;
  44. -ms-flex-flow:row-reversewrap-reverse;
  45. flex-flow:row-reversewrap-reverse;
  46. }
  47. .item{
  48. font-size:30px;
  49. padding:20px;
  50. height:100px;
  51. width:calc(100vw/3);
  52. height:calc(100vh/4);
  53. -webkit-animation:appearboth;
  54. animation:appearboth;
  55. }
  56. .item:nth-child(1){
  57. background:#008a8a;
  58. -webkit-animation-delay:0.03333s!important;
  59. -webkit-animation-duration:0.1s!important;
  60. }
  61. .item:nth-child(2){
  62. background:#009494;
  63. -webkit-animation-delay:0.06667s!important;
  64. -webkit-animation-duration:0.2s!important;
  65. }
  66. .item:nth-child(3){
  67. background:#009f9f;
  68. -webkit-animation-delay:0.1s!important;
  69. -webkit-animation-duration:0.3s!important;
  70. }
  71. .item:nth-child(4){
  72. background:#00a9a9;
  73. -webkit-animation-delay:0.13333s!important;
  74. -webkit-animation-duration:0.4s!important;
  75. }
  76. .item:nth-child(5){
  77. background:#00b3b3;
  78. -webkit-animation-delay:0.16667s!important;
  79. -webkit-animation-duration:0.5s!important;
  80. }
  81. .item:nth-child(6){
  82. background:#00bdbd;
  83. -webkit-animation-delay:0.2s!important;
  84. -webkit-animation-duration:0.6s!important;
  85. }
  86. .item:nth-child(7){
  87. background:#00c7c7;
  88. -webkit-animation-delay:0.23333s!important;
  89. -webkit-animation-duration:0.7s!important;
  90. }
  91. .item:nth-child(8){
  92. background:#00d2d2;
  93. -webkit-animation-delay:0.26667s!important;
  94. -webkit-animation-duration:0.8s!important;
  95. }
  96. .item:nth-child(9){
  97. background:#00dcdc;
  98. -webkit-animation-delay:0.3s!important;
  99. -webkit-animation-duration:0.9s!important;
  100. }
  101. .item:nth-child(10){
  102. background:#00e6e6;
  103. -webkit-animation-delay:0.33333s!important;
  104. -webkit-animation-duration:1s!important;
  105. }
  106. .item:nth-child(11){
  107. background:#00f0f0;
  108. -webkit-animation-delay:0.36667s!important;
  109. -webkit-animation-duration:1.1s!important;
  110. }
  111. .item:nth-child(12){
  112. background:#00fafa;
  113. -webkit-animation-delay:0.4s!important;
  114. -webkit-animation-duration:1.2s!important;
  115. }
  116. @-webkit-keyframesappear{
  117. from{
  118. opacity:0;
  119. -webkit-transform:scale(0.8);
  120. transform:scale(0.8);
  121. }
  122. to{
  123. opacity:1;
  124. -webkit-transform:scale(1);
  125. transform:scale(1);
  126. }
  127. }
  128. @keyframesappear{
  129. from{
  130. opacity:0;
  131. -webkit-transform:scale(0.8);
  132. transform:scale(0.8);
  133. }
  134. to{
  135. opacity:1;
  136. -webkit-transform:scale(1);
  137. transform:scale(1);
  138. }
  139. }
  140. @-webkit-keyframesdisappear{
  141. from{
  142. opacity:1;
  143. -webkit-transform:scale(1);
  144. transform:scale(1);
  145. }
  146. to{
  147. opacity:0;
  148. -webkit-transform:scale(0.9)rotateX(0deg)translateZ(-1500px);
  149. transform:scale(0.9)rotateX(0deg)translateZ(-1500px);
  150. }
  151. }
  152. @keyframesdisappear{
  153. from{
  154. opacity:1;
  155. -webkit-transform:scale(1);
  156. transform:scale(1);
  157. }
  158. to{
  159. opacity:0;
  160. -webkit-transform:scale(0.9)rotateX(0deg)translateZ(-1500px);
  161. transform:scale(0.9)rotateX(0deg)translateZ(-1500px);
  162. }
  163. }

到此这篇关于一款基于css3的列表toggle特效实例好代码教程就介绍到这了。青春啊,永远是美好的,可是真正的青春,只属于这些永远力争上游的人,永远忘我劳动的人,永远谦虚的人。更多相关一款基于css3的列表toggle特效实例好代码教程内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!