jquery和CSS3帶倒影的3D萬花筒旋轉動畫特效效果示範

來源:互聯網
上載者:User

標籤:use   src   rip   ons   com   class   img   擷取   console   

<!DOCTYPE html><html>        <head>                <title></title>                <meta charset=‘utf-8‘ />                <script src=‘js/jquery.js‘></script>                <style>                        .pic{                            width: 120px;                            height: 180px;                            margin: 150px auto 0;                            position: relative;                            /*transform 旋轉元素*/                            transform-style:preserve-3d;                            transform:perspective(800px) rotateX(-10deg) rotateY(0deg);                        }                        .pic img{                            position: absolute;                            width: 100%;                            height: 100%;                            border-radius: 5px;                            box-shadow: 0px 0px 10px #fff;                            /*倒影的設定*/                            -webkit-box-reflect:below 10px -webkit-linear-gradient(top,rgba(0,0,0,0) 50%,rgba(0,0,0,.5) 100%);                        }                        .pic p{                            width: 1200px;                            height: 1200px;                            background: -webkit-radial-gradient(center center,600px 600px,rgba(255,255,255,.5),rgba(0,0,0,0));                            position: absolute;                            top:100%;left:50%;                            margin-top: -600px;                            margin-left: -600px;                            border-radius:600px;                            transform:rotateX(90deg);                        }                     </style>        </head>        <body>                <div class=‘box‘>                        <div class="pic">                                <img src="image/1.jpg" />                                <img src="image/2.jpg" />                                <img src="image/3.jpg" />                                <img src="image/4.jpg" />                                <img src="image/5.jpg" />                                <img src="image/6.jpg" />                                <img src="image/7.jpg" />                                <img src="image/8.jpg" />                                <img src="image/9.jpg" />                                <img src="image/10.jpg" />                                <p></p>                        </div>                </div>                <script>                        $(function () {                            var imgL = $(".pic img").size();                            var deg = 360 / imgL;                            var roY = 0, roX = -10;                            var xN = 0, yN = 0;                                    var play = null;                                    $ (".pic  img").each(function(i){                            $(this).css({                            "transform":"rotateY( " + i * deg + "deg) translateZ(200px)" });                                     $(this).attr(‘ondragstart‘, ‘return false‘);                        });                        $(document).mousedown(function (ev) {                            var x_ = ev.clientX;                            var y_ = ev.clientY;                            clearInterval(play);                            console.log(‘我按下了‘);                            $(this).bind(‘mousemove‘, function (ev) {                                /*擷取當前滑鼠的座標*/                                var x = ev.clientX;                                var y = ev.clientY;                                /*兩次座標之間的距離*/                                xN = x - x_;                                yN = y - y_;                                roY += xN * 0.2;                                roX -= yN * 0.1;                                console.log(‘移動‘);                                $(‘.pic‘).css({                                    transform: ‘perspective(800px) rotateX(‘ + roX + ‘deg) rotateY(‘ + roY + ‘deg)‘                                });                                /*之前的滑鼠座標*/                                x_ = ev.clientX;                                y_ = ev.clientY;                            });                        }).mouseup(function () {                            $(this).unbind(‘mousemove‘);                            var play = setInterval(function () {                                xN *= 0.95;                                yN *= 0.95;                                if (Math.abs(xN) < 1 && Math.abs(yN) < 1) {                                    clearInterval(play);                                }                                roY += xN * 0.2;                                roX -= yN * 0.1;                                $(‘.pic‘).css({                                    transform: ‘perspective(800px) rotateX(‘ + roX + ‘deg) rotateY(‘ + roY + ‘deg)‘                                });                            }, 30);                        });                 });                </script>        </body></html>

原文出處:http://www.htmleaf.com/jQuery/list_1_5.html

  

jquery和CSS3帶倒影的3D萬花筒旋轉動畫特效效果示範

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.