×

CSS3转动的三围正方体

作者:andy0012018.11.26来源:Web前端之家浏览:12459评论:0
关键词:CSS3

CSS3转动的三围正方体。

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
     <style>
         .box {
            height: 250px;
            width:250px;
            border:brown solid 1px;
            margin:100px auto; 
            position: relative;
            /* 将平面的变的有立体感 */
            transform-style: preserve-3d;
            /* 过渡效果 */
            transition: all 1s;
            /* 使用动画*/
            animation: move 5s infinite;

         }
         .box div {
            height: 100%;
            width:100%;
            position: absolute;
            top:0px;
            left:0px;
         }

         .top {

             transform:rotateX(90deg) translateZ(125px);
             background: url(./1.jpg);
         }
         .before {
             transform: rotateX(180deg) translateZ(125px);
             background: url(./2.jpg);
         }
         .bottom {
             transform: rotateX(270deg) translateZ(125px);
             background: url(./3.jpg);
         }
         .left {
             transform: rotateY(90deg) translateZ(125px);
             background: url(./4.jpg);
         }
         .right {
            transform: rotateY(270deg) translateZ(125px);
            background: url(./5.jpg);
         }
         .after {
            transform:translateZ(125px);
            background: url(./6.jpg);
         }
         /* 设置动画 --此处相当于定义动画*/
         @keyframes move {
             0% {
                 transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
             }
             20% {
                transform: rotateX(90deg) rotateY(90deg) rotateZ(90deg);
             }
             40% {
                transform: rotateX(180deg) rotateY(180deg) rotateZ(180deg);
             }
             60% {
                transform: rotateX(90deg) rotateY(90deg) rotateZ(90deg);
             }
             80% {
                transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); 
             }
             100% {
                transform: rotateX(-90deg) rotateY(-90deg) rotateZ(-90deg);
             }
         }
     </style>
</head>
<body>
    <div class="box">
        <!-- 上面 -->
        <div class="top"> </div>
        <!-- 下面 -->
        <div class="bottom"></div>
        <!-- 前面 -->
        <div class="after"></div>
        <!-- 后面 -->
        <div class="before"></div>
        <!-- 左面 -->
        <div class="left"></div>
        <!-- 右面 -->
        <div class="right"> </div>
    </div>
</body>
</html>


您的支持是我们创作的动力!
温馨提示:本文作者系 ,经Web前端之家编辑修改或补充,转载请注明出处和本文链接:
https://jiangweishan.com/article/css3htjksdjfksj.html

网友评论文明上网理性发言 已有0人参与

发表评论: