html实现百叶窗效果
来源:互联网 发布:windows打补丁 编辑:程序博客网 时间:2024/04/20 23:39
html实现百叶窗效果
原理很简单就是相当于把图片分成n份开始轮播,下面开始上代码并解析其步骤
style中的代码
* { margin: 0px; padding: 0px; } /*当然这里要用到绝对定位*/ .byc { width: 1280px; height: 720px; position: relative; } /*想分成几份 子容器的宽度就是父容器的宽度/份数 也要用定位超出的部分让其隐藏*/ .byc>div { width: 160px; height: 720px; float: left; position: relative; overflow: hidden; } .byc>div>p { width: 160px; height: 720px; position: absolute; } /*添加图片 本次实例用了五张图片*/ .byc>div>p:nth-child(1) { background: url(img/1.jpg); } .byc>div>p:nth-child(2) { background: url(img/2.jpg); } .byc>div>p:nth-child(3) { background: url(img/3.jpg); } .byc>div>p:nth-child(4) { background: url(img/4.jpg); } .byc>div>p:nth-child(5) { background: url(img/5.jpg); } /*定义每部分的位置*/ .byc>div:nth-child(2) p { background-position: -160px 0px; } .byc>div:nth-child(3) p { background-position: -320px 0px; } .byc>div:nth-child(4) p { background-position: -480px 0px; } .byc>div:nth-child(5) p { background-position: -640px 0px; } .byc>div:nth-child(6) p { background-position: -800px 0px; } .byc>div:nth-child(7) p { background-position: -960px 0px; } .byc>div:nth-child(8) p { background-position: -1120px 0px; } /*定义动画效果*/ @-webkit-keyframes show { 0% { left: 160px } 100% { left: 0px } } @-webkit-keyframes hide { 0% { left: 0px } 100% { left: -160px } } .in { -webkit-animation: show 0.5s; left: 0px; } .out { -webkit-animation: hide 0.5s; left: 160px; }
body代码,这个没啥好解释的
<div class="byc"> <div><p></p><p></p><p></p><p></p><p></p></div> <div><p></p><p></p><p></p><p></p><p></p></div> <div><p></p><p></p><p></p><p></p><p></p></div> <div><p></p><p></p><p></p><p></p><p></p></div> <div><p></p><p></p><p></p><p></p><p></p></div> <div><p></p><p></p><p></p><p></p><p></p></div> <div><p></p><p></p><p></p><p></p><p></p></div> <div><p></p><p></p><p></p><p></p><p></p></div> </div>
script代码
$(function() { var i = 0; setInterval(function() { $(".byc>div").each(function(index, Element) { $(Element).children("p").eq(i).removeClass("out").addClass("in").siblings().removeClass("in").addClass("out"); }); i++; if(i == 7) { i = 0; } }, 2000); });
0 0
- html实现百叶窗效果
- J2ME实现百叶窗效果
- 网页图片实现百叶窗效果
- 利用Jquery实现百叶窗效果
- 用JavaScript实现页面百叶窗效果
- AS3.0实现百叶窗过渡效果
- python 简单实现 图片百叶窗效果
- javascript实现七屏百叶窗效果
- Android 百叶窗图片切换效果实现
- flex 百叶窗效果
- flex百叶窗效果
- felx百叶窗效果
- 窗体百叶窗效果
- 百叶窗效果集
- css 百叶窗效果
- css3百叶窗效果
- Html-百叶窗特效
- 实现百叶窗效果图
- 什么样的程序员适合去创业公司
- Oracle 11g DataGuard 配置详细说明
- Java——通过反射获取函数参数名称
- 数据降维知识40题(附答案)
- ligerUI
- html实现百叶窗效果
- Greenplum数据库安装手册 V1.0
- Qt-QML-Slider-滑块-Style
- POJ 2533 Longest Ordered Subsequence(最长上升子序列DP)
- 【LeetCode】字符串系列(子串)
- HDU 4770 Lights Against Dudely 【状态压缩+暴力枚举】
- 栈的使用-迷宫算法实现代码-摘自数据结构实现java版本(个人笔记整理)
- HTML常用标签
- 【源码剖析】MemoryPool —— 简单高效的内存池 allocator 实现