


HTML5 CSS3 exquisite case - details of realizing personalized slideshow on VCD packaging box
HTML5 CSS3 exquisite case - details of realizing personalized slideshow on VCD packaging box
Rendering:
Isn’t the image switching very personalized? , the effect is also very good, you can use it on your own website.
Look at the html first:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <meta content="text/html;charset=utf-8" http-equiv="content-type"> <link type="text/css" href="reset.css" rel="stylesheet"> <link type="text/css" href="main.css" rel="stylesheet"> <script type="text/javascript" src="../../jquery-1.8.3.js"></script> <script type="text/javascript" src="vcd.js"></script> <script type="text/javascript"> $(function () { vcd.init(); vcd.autoPlay(); }); </script> </head> <body> <p id="vcd"> <i id="cd"></i> <ul> <li class="active"><a><img alt="超人归来" src="ad/1.jpg"/></a></li> <li><a><img alt="超凡蜘蛛侠" src="ad/2.jpg"/></a></li> <li><a><img alt="黑暗骑士:蝙蝠侠" src="ad/3.jpg"/></a></li> <li><a><img alt="美国队长" src="ad/4.jpg"/></a></li> <li><a><img alt="雷神托儿" src="ad/5.jpg"/></a></li> <li><a><img alt="金刚狼" src="ad/6.jpg"/></a></li> </ul> <a id="wrapPager" title="超人归来" target="_blank"></a> <p id="indexBar"> <a class="active">0</a> <a href="#">1</a> <a href="#">2</a> <a href="#">3</a> <a href="#">4</a> <a href="#">5</a> </p> </p> </body> </html>
You can see that p#vcd is the outermost container, and a background is set for it; ul li sets the picture elements separately; i#cd Set the background to the CD, and then set the display position; display the index of the picture in p#indexBar for clicks.
CSS:
#vcd, #vcd ul, #vcd #wrapPager { width: 200px; height: 272px; } #vcd, #vcd ul, #vcd #wrapPager, #cd { background: url("images/disk.png") no-repeat 0 0; } #vcd { position: relative; margin: 20px auto 0; } #vcd ul, #vcd #wrapPager, #cd { position: absolute; } #vcd ul { background-position: -263px 3px; } #vcd ul li, #vcd ul li a, #vcd ul li a img { display: block; width: 178px; height: 264px; overflow: hidden; } #vcd ul li { top: 5px; left: 2px; opacity: 0; /*visibility: hidden;*/ -webkit-transition: opacity linear .6s; /*-webkit-transition: visibility linear .6s;*/ -moz-transition: opacity linear .6s; -ms-transition: opacity linear .6s; transition: opacity linear .6s; position: absolute; } #vcd ul li.active { opacity: 1; /*visibility: visible;*/ } #vcd #cd { top: 64px; left: 78px; width: 146px; height: 146px; background-position: -510px 0; -webkit-transition: left ease .4s, -webkit-transform ease 1.2s .44s; -moz-transition: left ease .4s, -moz-transform ease 1.2s .44s; -ms-transition: left ease .4s, -ms-transform ease 1.2s .44s; transition: left ease .4s, transform ease 1.2s .44s; } #vcd #cd.switch { left: 120px; -webkit-transform: rotate(2520deg); -moz-transform: rotate(2520deg); -ms-transform: rotate(2520deg); transform: rotate(2520deg); } #vcd #wrapPager { display: block; left: 0; top: 2px; } #vcd #indexBar { top: 235px; left: 25px; text-align: center; overflow: hidden; opacity: 0; visibility: hidden; -webkit-transition: opacity linear .6s; -moz-transition: opacity linear .6s; -ms-transition: opacity linear .6s; transition: opacity linear .6s; position: absolute; } #vcd:hover #indexBar { opacity: 1; visibility: visible; } #vcd #indexBar a { display: inline-block; margin: 0 4px; height: 0; width: 0; border: 4px #9f9f9f solid; border-radius: 100%; text-indent: -200px; overflow: hidden; } #vcd #indexBar a:hover, #vcd #indexBar a.active { width: 4px; height: 4px; border-color: #05c7fe; border-width: 2px; }
You can follow the CSS, the layout of the position is mainly It just relies on position:relative and position:absolute; and then you will find the transition and transformation using CSS3: transition and transform. Let me briefly mention:
1, transition: left 1s ease 0s;
Parameter 1: The attribute that requires transition effect can be a single attribute: width, left, etc., or it can be set to all.
Parameter 2: The duration of the transition
Parameter 3: The speed animation of the transition. If you are interested, you can check this. It is slow first and then fast, uniform speed and so on.
Parameter 4: Delay time for transition start
Transition also supports the following writing:
transition-property: border, color, text-shadow;
transition-duration:2s, 3s, 3s;
2. Transform supports several deformations
transform:scale(0.5) scaling
transform:rotate(90deg)rotation 90 degrees
transform:skew(10deg 2deg) obliquely cut, the rectangle is converted into a parallelogram
transform:matrix() This matrix is transformed http://www.php .cn/ This website provides an online design matrix
transform:translate(40px 20px) translation
Exception provides: transform-origin: 20% 20%; used to modify the transformation effect The starting point defaults to the key
Of course, our example uses rotation, so there is no need to modify the starting point of the deformation effect.
Finally, JS:
/** * Created with JetBrains WebStorm. * User: zhy * Date: 14-6-15 * Time: 下午6:26 * To change this template use File | Settings | File Templates. */ var vcd = { /** * 常量 */ ID_VCD: "vcd", ID_INDEXBAR: "indexBar", ID_CD: "cd", CLASS_ACTIVE: "active", CLASS_CD_SWITCH: "switch", currentIndex: 0, isRunning: false, timer: null, init: function () { /** * 初始化数据与事件 */ vcd.vcd = $("#" + vcd.ID_VCD); vcd.cd = $("#" + vcd.ID_CD); vcd.imgs = $("li", vcd.vcd); vcd.indexBar = $("#" + vcd.ID_INDEXBAR); vcd.vcd.mouseover(function (event) { clearInterval(vcd.timer); }); vcd.vcd.mouseout(function () { vcd.autoPlay(); }) ; $("a", vcd.indexBar).click(vcd.dotClick); }, /** * 按钮点击切换 * @param event */ dotClick: function (event) { //如果当前动画还在运行,则直接返回 if (vcd.isRunning)return; vcd.isRunning = true; $("a", vcd.indexBar).removeClass(vcd.CLASS_ACTIVE); $(this).addClass(vcd.CLASS_ACTIVE); vcd.currentIndex = $(this).text(); vcd.cd.addClass(vcd.CLASS_CD_SWITCH); setTimeout(vcd.resetDotClick, 1500); event.preventDefault();//阻止a的默认跳转页面 }, /** * 当cd动画结束后,更新图片 */ resetDotClick: function () { vcd.cd.removeClass(vcd.CLASS_CD_SWITCH); vcd.imgs.removeClass(vcd.CLASS_ACTIVE); vcd.imgs.eq(vcd.currentIndex).addClass(vcd.CLASS_ACTIVE); vcd.isRunning = false; }, autoClick: function () { var as = $("a", vcd.indexBar); vcd.currentIndex++; if (vcd.currentIndex == as.length) { vcd.currentIndex = 0; } as.removeClass(vcd.CLASS_ACTIVE); as.eq(vcd.currentIndex).addClass(vcd.CLASS_ACTIVE); vcd.cd.addClass(vcd.CLASS_CD_SWITCH); setTimeout(vcd.resetDotClick, 1500); }, /** * 自动播放 */ autoPlay: function () { vcd.timer = setInterval(function () { vcd.autoClick(); }, 3000); } } ;
The way to write a singleton is to define an object, and then the user Called through vcd.init(); vsd.autoPlay(),
<script type="text/javascript"> $(function () { vcd.init(); vcd.autoPlay(); }); </script>
The above is the detailed content of HTML5 CSS3 exquisite case - details of realizing personalized slideshow on VCD packaging box. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.
