web299.com
全部
教育
语言/资格考试
法律
互联网
政务民生
Word模板
Excel模板
PPT模板
网页特效
小程序模板
网站模板
首页
教育
语言/资格考试
法律
互联网
政务民生
Word模板
Excel模板
PPT模板
网页特效
小程序模板
网站模板
当前位置:
首页
>
网页特效
>
其他
windows8 Metro风格打开面板动画UI设计
分类:
其他
日期:
2024-05-14
点击(0)
评论(0)
演 示
免费下载
简介
##### HTML结构 该windows 8 Metro风格UI设计的HTML结构使用一个无序列表来制作网格布局,里面放置的是各个面板。div.box是打开的全屏面板。 ```html
Games
Settings
Email
Messages
Music
Favorites
Photos
``` ##### CSS样式 在无序列表的网格布局中,为制作透视效果,每一个列表项都设置了perspective属性。 ```html .metro li { -webkit-transform: perspective(600px); -webkit-transform-style: preserve-3d; -webkit-transform-origin-x: 50%; -webkit-transform-origin-y: 50%; -ms-transform: perspective(600px); -ms-transform-style: preserve-3d; -ms-transform-origin-x: 50%; -ms-transform-origin-y: 50%; transform: perspective(600px); transform-style: preserve-3d; transform-origin-x: 50%; transform-origin-y: 50%; cursor: default; position: relative; text-align: center; margin: 0 10px 10px 0; width: 150px; height: 150px; color: #ffffff; float: left; -webkit-transition: .2s -webkit-transform, 1s opacity; -ms-transition: .2s -ms-transform, 1s opacity; transition: .2s transform, 1s opacity; cursor:pointer; } ``` x和y方向上的转换原点都被设置为50%,这是为了在点击小面板时制作3D效果,你会发现鼠标点击不同的小面板不松开时,会有不同的3D转换效果。这是通过nth-child选择器和不同的transform来配合完成的。 ```html .metro li:nth-child(5):active, .metro li:first-child:active { -webkit-transform: scale(0.95); -ms-transform: scale(0.95); transform: scale(0.95); } .metro li:nth-child(7):active, .metro li:nth-child(2):active { -webkit-transform: perspective(600px) rotate3d(1, 0, 0, -10deg); -ms-transform: perspective(600px) rotate3d(1, 0, 0, -10deg); transform: perspective(600px) rotate3d(1, 0, 0, -10deg); } .metro li:nth-child(3):active { -webkit-transform: perspective(600px) rotate3d(0, 1, 0, 10deg); -ms-transform: perspective(600px) rotate3d(0, 1, 0, 10deg); transform: perspective(600px) rotate3d(0, 1, 0, 10deg); } .metro li:nth-child(4):active { -webkit-transform: perspective(600px) rotate3d(0, 1, 0, -10deg); -ms-transform: perspective(600px) rotate3d(0, 1, 0, -10deg); transform: perspective(600px) rotate3d(0, 1, 0, -10deg); } .metro li:nth-child(6):active { -webkit-transform: perspective(600px) rotate3d(1, 0, 0, 10deg); -ms-transform: perspective(600px) rotate3d(1, 0, 0, 10deg); transform: perspective(600px) rotate3d(1, 0, 0, 10deg); } ``` 在大面板.box的打开动画中,也是使用了旋转和缩放,配合适当的过渡动画来制作出3D效果。 ```html .box { display: table; top: 0; visibility: hidden; -webkit-transform: perspective(1200px) rotateY(180deg) scale(0.1); -ms-transform: perspective(1200px) rotateY(180deg) scale(0.1); transform: perspective(1200px) rotateY(180deg) scale(0.1); top: 0; left: 0; z-index: -1; position: absolute; width: 100%; height: 100%; opacity: 0; transition: 1s all; } .box.open { left: 0; top: 0; visibility: visible; opacity: 1; z-index: 999; -webkit-transform: perspective(1200px) rotateY(0deg) scale(1); -ms-transform: perspective(1200px) rotateY(0deg) scale(1); transform: perspective(1200px) rotateY(0deg) scale(1); width: 100%; height: 100%; } ``` ##### JavaScript 你会发现点击不同颜色的小面板时打开的大面板和小面板的颜色是相同的,这是在jQuery代码中实现的,代码中还会为打开的面板添加.openclass和添加文本内容。 ```html $(document).ready(function () { var $box = $('.box'); $('.metro li').each(function () { var color = $(this).css('backgroundColor'); var content = $(this).html(); $(this).click(function () { $box.css('backgroundColor', color); $box.addClass('open'); $box.find('p').html(content); }); $('.close').click(function () { $box.removeClass('open'); $box.css('backgroundColor', 'transparent'); }); }); }); ```
相关推荐
html5浪漫粒子表白文字特效
SlidesJS幻灯片特效
html5瀑布流相册特效
css3 svg实现的情人节表白鲜花动画特效
t-scroll.js基于ES6的DOM元素,过渡动画库插件
纯js写省市区三级联动效果
广告
广告