Day05(demo 3d旋转 3d立方体 立体轮播)

demo 3d旋转

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            body{
                margin: 0;
                padding: 0;
                background: #b3c04c;
            }
            .wa{
                width: 300px;
                height: 300px;
                margin: 50px auto;
                position: relative;
            }
            .wa::before,.wa::after{
                content: '';
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                height: 100%;
                border-radius: 150px;
                transition: all 0.6s;
                backface-visibility: hidden;/*背面隐藏*/
            }
            .wa::before{
                background: url(bg.png) left top;
                transform: rotateY(0deg);
            }
            
            .wa::after{
                background: url(bg.png) right top;
                transform: rotateY(180deg);
            }
            .wa:hover::before{
                transform: rotateY(180deg);
            }
            .wa:hover::after{
                transform: rotateY(0deg);
            }
        </style>
    </head>
    <body>
        <div class="wa">
            
        </div>
    </body>
</html>

demo 3d立方体

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            *{margin: 0;padding: 0;}
            ul{list-style: none;}
            ul{
                width: 200px;
                height: 200px;
                margin: 100px auto;
                position: relative;
                transition: all 3s;
                transform-style: preserve-3d; 
            }
            ul li{
                width: 100%;
                height: 100%;
                text-align: center;
                line-height: 200px;
                color: #fff;
                font-size: 40px;
                position: absolute;
            }
            ul li:nth-child(1){
                transform: rotateX(0deg) translateZ(100px);
                background: rgba(200,0,0,0.6);
            }
            ul li:nth-child(2){
                transform: rotateX(-90deg) translateZ(100px);
                background: rgba(0,255,0,0.6);
            }
            ul li:nth-child(3){
                transform: rotateX(-180deg) translateZ(100px);
                background: rgba(0,0,255,0.6);
            }
            ul li:nth-child(4){
                transform: rotateX(-270deg) translateZ(100px);
                background: rgba(0,255,255,0.6);
            }
            ul li:nth-child(5){
                transform: rotateY(-90deg) translateZ(100px);
                background: rgba(255,0,255,0.6);
            }
            ul li:nth-child(6){
                transform: rotateY(90deg) translateZ(100px);
                background: rgba(23,0,45,0.6);
            }
            ul:hover{
                transform: rotateX(360deg) rotateY(90deg);
            }
        </style>
    </head>
    <body>
        <ul>
            <li>第一面</li>
            <li>第二面</li>
            <li>第三面</li>
            <li>第四面</li>
            <li>第五面</li>
            <li>第六面</li>
        </ul>
    </body>
    
    
    <script type="text/javascript">
        $(".b").mouseenter()
    </script>
    
</html>

demo 立体轮播

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style type="text/css">
        *{margin: 0;padding: 0;}
        ul{list-style: none;}
        body{margin: 0;padding-top: 0;background: #F7F7F7;}
        
        .cut{
            height: 300px;
            width: 560px;
            margin: 100px auto;
            background: cyan;
            position: relative;
        }
        .prev,.next{
            display: block;
            width: 60px;
            height: 60px;
            text-align: center;
            line-height: 60px;
            margin-top: -30px;
            font-size: 40px;
            text-decoration: none;
            background: rgba(0,0,0,0.5);
            position: absolute;
            top: 50%;
            color: #fff;
        }
        .next{
            right: 0;
        }
        .cut li{
            position: absolute;
            top: 0;
            width: 112px;
            height: 100%;
            transform-style: preserve-3d;
            transition: all 1s;
        }
        .cut li div{
            width: 100%;
            height: 100%;
            position: absolute;
        }
        .cut li div:nth-of-type(1){
            background: url(images/1.png) no-repeat;
            transform: rotateX(0deg) translateZ(150px);
        }
        .cut li div:nth-of-type(2){
            background: url(images/2.png) no-repeat;
            transform: rotateX(-90deg) translateZ(150px);
        }
        .cut li div:nth-of-type(3){
            background: url(images/3.png) no-repeat;
            transform: rotateX(-180deg) translateZ(150px);
        }
        .cut li div:nth-of-type(4){
            background: url(images/4.png) no-repeat;
            transform: rotateX(-270deg) translateZ(150px);
        }
    </style>
    <script type="text/javascript" src="jquery-3.2.1.min.js" ></script>
    <script type="text/javascript">
        $(function(){
            $('li').each(function(index,ele){
                $(this).css({'left':560/5*index,"transition-delay":''+index*0.2+'s'});
                $(this).find('div').css({backgroundPosition:-560/5*index+"px 0"})
            })
            var num = 0;
            $('.next').on('click',function(){
                num++;
                $('li').css('transform','rotateX('+num*90+'deg)');
            });
            $('.prev').on('click',function(){
                num--;
                $('li').css('transform','rotateX('+num*90+'deg)');
            });
        });
    </script>
</head>
<body>
    <div class="cut">
        <ul>
            <li>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
            </li>
            <li>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
            </li>
            <li>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
            </li>
            <li>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
            </li>
            <li>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
            </li>
        </ul>
        <a href="javascript::" class="prev">&lt;</a>
        <a href="javascript::" class="next">&gt;</a>
    </div>
</body>
</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 今次就来个大家用3D属性最爱炫技的场景,旋转的立方体,有人声称这种动画简直代表了CSS3的癫疯,不不,是巅峰。做完...
    泱泱悲秋阅读 8,821评论 0 6
  • 把立方体的盒子搭出来之后,因为怕文章又臭又长(嗯,就是没有想好玩什么效果,偏不告诉你)关于动效没有做更多的处理,只...
    泱泱悲秋阅读 2,141评论 1 8
  • 一直想写一个带倒影效果的3D轮播图,最近有时间,就研究了一下,下面是实现后的效果,可无限循环轮播: 倒影 首先是倒...
    ThinkerH阅读 2,317评论 0 15
  • 先上效果图: 分析:看效果图,其实是好多些长方体在旋转。效果中一共有4幅图,把每幅图都切割成一长条一长条,然后这四...
    TsingXu阅读 1,303评论 0 2
  • 阅读是很平常的事情,但我一个月差不多只能读完2本书,总觉得时间不够用,还觉得读完书后,好像跟没 读过的感觉,和作者...
    李静_7285阅读 180评论 0 9