码迷,mamicode.com
首页 > Web开发 > 详细

利用css3渐变效果实现圆环旋转效果

时间:2017-04-08 19:35:35      阅读:1401      评论:0      收藏:0      [点我收藏+]

标签:auto   function   one   hid   doc   图片   city   lis   div   

* {
            margin: 0;
            padding: 0;
        }
        
        .stage {
            width: 200px;
            height: 130px;
            margin: 100px auto;
            position: relative;
            perspective: 1300px;
            perspective-origin: 100px -400px;
        }
        
        .stage ul {
            list-style: none;
            width: 100%;
            height: 100%;
        }
        
        img {
            backface-visibility: hidden;
        }
        
        #ring {
            width: 200px;
            height: 130px;
            position: absolute;
            top: 0;
            /*transform: rotateY(0deg);*/
            left: 0;
            transform-style: preserve-3d;
            transition: all 1s ease 0s;
        }
        
        .stage ul li {
            position: absolute;
            top: 0;
            left: 0;
            /*transform-origin: 30% 50%;*/
        }
        
        .stage ul li:nth-of-type(1) {
            transform: rotateY(0deg) translateZ(308px);
        }
        
        .stage ul li:nth-of-type(2) {
            transform: rotateY(36deg) translateZ(308px);
        }
        
        .stage ul li:nth-of-type(3) {
            transform: rotateY(72deg) translateZ(308px);
        }
        
        .stage ul li:nth-of-type(4) {
            transform: rotateY(108deg) translateZ(308px);
        }
        
        .stage ul li:nth-of-type(5) {
            transform: rotateY(144deg) translateZ(308px);
        }
        
        .stage ul li:nth-of-type(6) {
            transform: rotateY(180deg) translateZ(308px);
        }
        
        .stage ul li:nth-of-type(7) {
            transform: rotateY(216deg) translateZ(308px);
        }
        
        .stage ul li:nth-of-type(8) {
            transform: rotateY(252deg) translateZ(308px);
        }
        
        .stage ul li:nth-of-type(9) {
            transform: rotateY(288deg) translateZ(308px);
        }
        
        .stage ul li:nth-of-type(10) {
            transform: rotateY(324deg) translateZ(308px);
        }
        
        h2 {
            position: absolute;
            z-index: 10;
            opacity: 0.8;
            color: hotpink;
        }
window.onload = function() {
            var ring = document.getElementById(‘ring‘);
            var lis = ring.getElementsByTagName(‘li‘);

            for (var i = 0; i < lis.length; i++) {
                lis[i].idx = i;
                lis[i].onclick = function() {
                    ring.style.transform = ‘rotateY(-‘ + (this.idx * 36) + ‘deg)‘;
                }
            }
        }
 <div class="stage">
        <h2>点我我到最前面</h2>
        <ul id="ring">

            <li><img src="images/88/1.jpg" ></li>
            <li><img src="images/88/2.jpg" ></li>
            <li><img src="images/88/3.jpg" ></li>
            <li><img src="images/88/4.jpg" ></li>
            <li><img src="images/88/5.jpg" ></li>
            <li><img src="images/88/10.jpg" ></li>
            <li><img src="images/88/6.jpg" ></li>
            <li><img src="images/88/7.jpg" ></li>
            <li><img src="images/88/8.jpg" ></li>
            <li><img src="images/88/9.jpg" ></li>
        </ul>
    </div>

图片的选择需要选择400*400的图片

利用css3渐变效果实现圆环旋转效果

标签:auto   function   one   hid   doc   图片   city   lis   div   

原文地址:http://www.cnblogs.com/qqfontofweb/p/6682664.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!