复制代码代码如下: !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 div id="vcd" i id="cd" /i ul li 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 div id="indexBar" a 0 /a a href="#" 1 /a a href="#" 2 /a a href="#" 3 /a a href="#" 4 /a a href="#" 5 /a /div /div
/body /html
可以看到div#vcd是最外层容器,给它设置了一个背景;ul li 分别设置图片元素;i#cd设置背景为光盘,然后设置显示位置;div#indexBar中显示图片的索引,供点击。
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; }