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


Posted in HTML / CSS onJanuary 04, 2015

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

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

实现的代码。

htm代码:

复制内容到剪贴板
  1. <div class='menu'>   
  2.         toggle visibility</div>   
  3.     <ul class='list reverse'>   
  4.         <li class='item'>Item 1</li>   
  5.         <li class='item'>Item 2</li>   
  6.         <li class='item'>Item 3</li>   
  7.         <li class='item'>Item 4</li>   
  8.         <li class='item'>Item 5</li>   
  9.         <li class='item'>Item 6</li>   
  10.         <li class='item'>Item 7</li>   
  11.         <li class='item'>Item 8</li>   
  12.         <li class='item'>Item 9</li>   
  13.         <li class='item'>Item 10</li>   
  14.         <li class='item'>Item 11</li>   
  15.         <li class='item'>Item 12</li>   
  16.     </ul>  

css3代码:

CSS Code复制内容到剪贴板
  1. * {   
  2.   -moz-box-sizing: border-box;   
  3.        box-sizing: border-box;   
  4. }   
  5.   
  6. body {   
  7.   margin: 0;   
  8.   padding: 0;   
  9.   font-family'Avenir Next';   
  10.   background#000;   
  11.   colorwhite;   
  12. }   
  13.   
  14. .menu {   
  15.   background: tomato;   
  16.   padding20px;   
  17.   positionabsolute;   
  18.   z-index: 1;   
  19.   height55px;   
  20.   top: 0;   
  21.   rightright50px;   
  22. }   
  23.   
  24. .list {   
  25.   -webkit-perspective: 100vw;   
  26.           perspective: 100vw;   
  27.   width: 100vw;   
  28.   height: 100vh;   
  29.   display: -webkit-flex;   
  30.   display: -ms-flexbox;   
  31.   display: flex;   
  32.   -webkit-flex-flow: column wrap;   
  33.       -ms-flex-flow: column wrap;   
  34.           flex-flow: column wrap;   
  35. }   
  36. .list.hidden {   
  37.   pointer-events: none;   
  38. }   
  39. .list.hidden .item {   
  40.   -webkit-animation: disappear both;   
  41.           animation: disappear both;   
  42.   -webkit-animation-direction: alternate;   
  43.           animation-direction: alternate;   
  44. }   
  45. .list.reverse {   
  46.   -webkit-flex-flow: row-reverse wrap-reverse;   
  47.       -ms-flex-flow: row-reverse wrap-reverse;   
  48.           flex-flow: row-reverse wrap-reverse;   
  49. }   
  50.   
  51. .item {   
  52.   font-size30px;   
  53.   padding20px;   
  54.   height100px;   
  55.   width: calc(100vw / 3);   
  56.   height: calc(100vh / 4);   
  57.   -webkit-animation: appear both;   
  58.           animation: appear both;   
  59. }   
  60.   
  61. .item:nth-child(1) {   
  62.   background#008a8a;   
  63.   -webkit-animation-delay: 0.03333s !important;   
  64.   -webkit-animation-duration: 0.1s !important;   
  65. }   
  66.   
  67. .item:nth-child(2) {   
  68.   background#009494;   
  69.   -webkit-animation-delay: 0.06667s !important;   
  70.   -webkit-animation-duration: 0.2s !important;   
  71. }   
  72.   
  73. .item:nth-child(3) {   
  74.   background#009f9f;   
  75.   -webkit-animation-delay: 0.1s !important;   
  76.   -webkit-animation-duration: 0.3s !important;   
  77. }   
  78.   
  79. .item:nth-child(4) {   
  80.   background#00a9a9;   
  81.   -webkit-animation-delay: 0.13333s !important;   
  82.   -webkit-animation-duration: 0.4s !important;   
  83. }   
  84.   
  85. .item:nth-child(5) {   
  86.   background#00b3b3;   
  87.   -webkit-animation-delay: 0.16667s !important;   
  88.   -webkit-animation-duration: 0.5s !important;   
  89. }   
  90.   
  91. .item:nth-child(6) {   
  92.   background#00bdbd;   
  93.   -webkit-animation-delay: 0.2s !important;   
  94.   -webkit-animation-duration: 0.6s !important;   
  95. }   
  96.   
  97. .item:nth-child(7) {   
  98.   background#00c7c7;   
  99.   -webkit-animation-delay: 0.23333s !important;   
  100.   -webkit-animation-duration: 0.7s !important;   
  101. }   
  102.   
  103. .item:nth-child(8) {   
  104.   background#00d2d2;   
  105.   -webkit-animation-delay: 0.26667s !important;   
  106.   -webkit-animation-duration: 0.8s !important;   
  107. }   
  108.   
  109. .item:nth-child(9) {   
  110.   background#00dcdc;   
  111.   -webkit-animation-delay: 0.3s !important;   
  112.   -webkit-animation-duration: 0.9s !important;   
  113. }   
  114.   
  115. .item:nth-child(10) {   
  116.   background#00e6e6;   
  117.   -webkit-animation-delay: 0.33333s !important;   
  118.   -webkit-animation-duration: 1s !important;   
  119. }   
  120.   
  121. .item:nth-child(11) {   
  122.   background#00f0f0;   
  123.   -webkit-animation-delay: 0.36667s !important;   
  124.   -webkit-animation-duration: 1.1s !important;   
  125. }   
  126.   
  127. .item:nth-child(12) {   
  128.   background#00fafa;   
  129.   -webkit-animation-delay: 0.4s !important;   
  130.   -webkit-animation-duration: 1.2s !important;   
  131. }   
  132.   
  133. @-webkit-keyframes appear {   
  134.   from {   
  135.     opacity: 0;   
  136.     -webkit-transform: scale(0.8);   
  137.             transform: scale(0.8);   
  138.   }   
  139.   to {   
  140.     opacity: 1;   
  141.     -webkit-transform: scale(1);   
  142.             transform: scale(1);   
  143.   }   
  144. }   
  145.   
  146. @keyframes appear {   
  147.   from {   
  148.     opacity: 0;   
  149.     -webkit-transform: scale(0.8);   
  150.             transform: scale(0.8);   
  151.   }   
  152.   to {   
  153.     opacity: 1;   
  154.     -webkit-transform: scale(1);   
  155.             transform: scale(1);   
  156.   }   
  157. }   
  158. @-webkit-keyframes disappear {   
  159.   from {   
  160.     opacity: 1;   
  161.     -webkit-transform: scale(1);   
  162.             transform: scale(1);   
  163.   }   
  164.   to {   
  165.     opacity: 0;   
  166.     -webkit-transform: scale(0.9) rotateX(0deg) translateZ(-1500px);   
  167.             transform: scale(0.9) rotateX(0deg) translateZ(-1500px);   
  168.   }   
  169. }   
  170. @keyframes disappear {   
  171.   from {   
  172.     opacity: 1;   
  173.     -webkit-transform: scale(1);   
  174.             transform: scale(1);   
  175.   }   
  176.   to {   
  177.     opacity: 0;   
  178.     -webkit-transform: scale(0.9) rotateX(0deg) translateZ(-1500px);   
  179.             transform: scale(0.9) rotateX(0deg) translateZ(-1500px);   
  180.   }   
  181. }  
HTML / CSS 相关文章推荐
CSS3动画之利用requestAnimationFrame触发重新播放功能
Sep 11 HTML / CSS
CSS3系列教程:背景图片(背景大小和多背景图) 应用说明
Dec 19 HTML / CSS
深入浅析css3 border-image边框图像详解
Nov 24 HTML / CSS
CSS3实现翘边的阴影效果的代码示例
Jun 13 HTML / CSS
使用 css3 实现圆形进度条的示例
Jul 05 HTML / CSS
css3给背景图片加颜色遮罩的方法
Nov 05 HTML / CSS
HTML5 Web存储方式的localStorage和sessionStorage进行数据本地存储案例应用
Dec 09 HTML / CSS
Canvas与图片压缩的示例代码
Nov 28 HTML / CSS
HTML5实现移动端弹幕动画效果
Aug 01 HTML / CSS
基于html5 canvas做批改作业的小插件
May 20 HTML / CSS
使用SVG实现提示框功能的示例代码
Jun 05 HTML / CSS
AmazeUI折叠式卡片布局,整合内容列表、表格组件实现
Aug 20 HTML / CSS
一款基于css3麻将筛子3D翻转特效的实例教程
Dec 31 #HTML / CSS
CSS Grid布局教程之网格单元格布局
Dec 30 #HTML / CSS
CSS Grid布局教程之浏览器开启CSS Grid Layout汇总
Dec 30 #HTML / CSS
CSS Grid布局教程之什么是网格布局
Dec 30 #HTML / CSS
使用CSS Grid布局实现网格的流动
Dec 30 #HTML / CSS
纯css3制作网站后台管理面板
Dec 30 #HTML / CSS
一款纯css3实现的鼠标悬停动画按钮
Dec 29 #HTML / CSS
You might like
30 个很棒的PHP开源CMS内容管理系统小结
2011/10/14 PHP
PHP判断是否有Get参数的方法
2014/05/05 PHP
PHP编译安装中遇到的两个错误和解决方法
2014/08/20 PHP
php创建多级目录的方法
2015/03/24 PHP
PHP实现通过URL提取根域名
2016/03/31 PHP
JQuery的html(data)方法与&amp;lt;script&amp;gt;脚本块的解决方法
2010/03/09 Javascript
js setTimeout 常见问题小结
2013/08/13 Javascript
javascript仿php的print_r函数输出json数据
2013/09/13 Javascript
用js闭包的方法实现多点标注冒泡示例
2014/05/29 Javascript
jQuery实现列表自动滚动循环滚动展示新闻
2014/08/22 Javascript
jQuery插件slick实现响应式移动端幻灯片图片切换特效
2015/04/12 Javascript
在Python中使用glob模块查找文件路径的方法
2015/06/17 Javascript
jquery实现表格隔行换色效果
2015/11/19 Javascript
实例详解AngularJS实现无限级联动菜单
2016/01/15 Javascript
jQuery简单实现MD5加密的方法
2017/03/03 Javascript
js遍历获取表格内数据的方法(必看)
2017/04/06 Javascript
Node.js简单入门前传
2017/08/21 Javascript
canvas绘制爱心的几种方法总结(推荐)
2017/10/31 Javascript
jQuery图片查看插件Magnify开发详解
2017/12/25 jQuery
vue实现简单加法计算器
2020/10/22 Javascript
Python OpenCV对本地视频文件进行分帧保存的实例
2019/01/08 Python
Django利用cookie保存用户登录信息的简单实现方法
2019/05/27 Python
使用CSS3的ruby-position固定注音位置的用法示例
2016/07/05 HTML / CSS
html5 利用重力感应实现摇一摇换颜色可用来做抽奖等等
2014/05/07 HTML / CSS
英国最大的电子产品和家电零售企业:Currys PC World
2016/09/24 全球购物
荷兰演唱会和体育比赛订票网站:viagogo荷兰
2018/04/08 全球购物
Harrods美国:英国最大的百货公司
2018/11/04 全球购物
L’urv官网:精品女性运动服品牌
2019/07/07 全球购物
医学生自我鉴定范文
2014/03/26 职场文书
实习评语大全
2014/04/26 职场文书
美丽家庭事迹材料
2014/05/03 职场文书
党员“四风”方面存在问题及整改措施
2014/09/24 职场文书
预备党员群众路线教育实践活动思想汇报2014
2014/10/25 职场文书
群众路线教育实践活动学习笔记
2014/11/05 职场文书
2015年营销工作总结范文
2015/04/23 职场文书
python实现简易自习室座位预约系统
2021/06/30 Python