Html5百叶窗效果的示例代码_html5教程技巧
h5
html5
百叶窗
本篇文章主要介绍了Html5百叶窗效果的示例代码,小编觉得挺不错的,现在分享给大家HTML5源码和解释,也给大家做个参考。对HTML5感兴趣的小伙伴可以一起跟随小编过来看看吧
本文介绍了Html5百叶窗效果的示例代码,分享给大家,具体如下:
实现方法介绍:
1,百叶窗布局 用定位(position: absolute)覆盖在content布局之上,背景设置为透明(background-color: transparent)
2,keyframes定义淡入淡出(透明度改变)和百叶窗口效果动画。
3,启动动画是通过设置DOM的className属性的方法,animator.className = 'baiyeWindow'; 监听动画完成事件'animationend',要清除className属性。
4,在内容布局切换的事件,调用启动动画方法,两个布局都需要绑定切换事件 ng-click="switchLayout()"
5,动画执行时序图:
html代码:
<!--要显示百叶窗效果的布局--切换内容--> <p id="fadeInOut" class="content" ng-click="switchLayout()"> ... </p> <!--百叶窗布局--> <ul id="baiyeWindow" ng-click="switchLayout()"> <li><p class="ye"></p></li> <li><p class="ye"></p></li> <li><p class="ye"></p></li> <li><p class="ye"></p></li> </ul>
登录后复制
css样式代码:
//谈入谈出效果 .fade-animation{ @-webkit-keyframes fadeInOut { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } } @keyframes fadeInOut { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } } animation: fadeInOut 1s ease-in; -webkit-animation: fadeInOut 1s ease-in; } //百叶窗效果 .baiyeWindow{ width: 100%; height: 1.68rem; position: absolute; left: 0; top: 1.2rem; li{ height: 0.42rem; line-height: 40px; overflow: hidden; background-color: transparent; .ye{ -webkit-animation: slideOut 1s ease-in-out; animation: slideOut 1s ease-in-out; width: 100%; background-color: rgba(0,0,0,.2); position: relative; top: 50%; } } @-webkit-keyframes slideOut { 0% { padding-bottom: 0; top: 50%; } 100% { padding-bottom: 40px; top: 0; } } @keyframes slideOut { 0% { padding-bottom: 0; top: 50%; } 100% { padding-bottom: 40px; top: 0; } } }
登录后复制
JS代码:
//切换布局 $scope.switchLayout = function(){ ... $scope.startBaiYeWindow(); //启动动画0.5s后,控制布局显示/隐藏 $timeout(function () { if ($scope.show) { $scope.show = false; } else { .... } }, 500); } //启动动画 $scope.startBaiYeWindow = function () { var animator = document.getElementById('baiyeWindow'); var animatorFadeInOut = document.getElementById('fadeInOut'); animator.addEventListener('animationend', function () { animator.className = ''; animatorFadeInOut.className = 'content'; }); $timeout(function () { animator.className = 'baiyeWindow'; animatorFadeInOut.className = 'content fade-animation'; }, 0); };
登录后复制
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持PHP中文网。
相关推荐:
以上是Html5百叶窗效果的示例代码_html5教程技巧的详细内容。更多信息请关注PHP中文网其他相关文章!
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章
Windows 11 KB5054979中的新功能以及如何解决更新问题
4 周前
By DDD
如何修复KB5055523无法在Windows 11中安装?
3 周前
By DDD
如何修复KB5055518无法在Windows 10中安装?
3 周前
By DDD
R.E.P.O.的每个敌人和怪物的力量水平
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
蓝王子:如何到达地下室
3 周前
By DDD

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)