css3 3d 효과

10108 단어 css3
<!--
@-webkit-keyframes move {
0% {
transform: rotateY(0deg);
}
100% {
transform: rotateY(360deg);
}
}
/* line 13, ../sass/test.scss */
body {
padding: 200px;
}
/* line 15, ../sass/test.scss */
.content {
width: 500px;
height: 500px;
margin: -350px auto;
border: 1px solid transparent;
position: relative;
-webkit-perspective: 500px;
-webkit-perspective-origin: center 100px;
}
/* line 24, ../sass/test.scss */
.content:nth-of-type(1) {
z-index: 9;
}
/* line 24, ../sass/test.scss */
.content:nth-of-type(2) {
z-index: 8;
}
/* line 24, ../sass/test.scss */
.content:nth-of-type(3) {
z-index: 7;
}
/* line 24, ../sass/test.scss */
.content:nth-of-type(4) {
z-index: 6;
}
/* line 24, ../sass/test.scss */
.content:nth-of-type(5) {
z-index: 5;
}
/* line 24, ../sass/test.scss */
.content:nth-of-type(6) {
z-index: 4;
}
/* line 24, ../sass/test.scss */
.content:nth-of-type(7) {
z-index: 3;
}
/* line 24, ../sass/test.scss */
.content:nth-of-type(8) {
z-index: 2;
}
/* line 24, ../sass/test.scss */
.content:nth-of-type(9) {
z-index: 1;
}
/* line 28, ../sass/test.scss */
.content .main {
width: 100px;
height: 100px;
margin: 200px auto;
position: relative;
transform-style: preserve-3d;
animation: move 8s linear infinite;
}
/* line 35, ../sass/test.scss */
.content .main div {
width: 100px;
height: 100px;
position: absolute;
bottom: 0;
font-size: 100px;
color: white;
text-align: center;
line-height: 100px;
transform-style: preserve-3d;
}
/* line 46, ../sass/test.scss */
.content .main div:nth-of-type(1) {
background: red;
transform: rotateY(45deg) translateZ(150px);
}
/* line 46, ../sass/test.scss */
.content .main div:nth-of-type(2) {
background: yellow;
transform: rotateY(90deg) translateZ(150px);
}
/* line 46, ../sass/test.scss */
.content .main div:nth-of-type(3) {
background: blue;
transform: rotateY(135deg) translateZ(150px);
}
/* line 46, ../sass/test.scss */
.content .main div:nth-of-type(4) {
background: green;
transform: rotateY(180deg) translateZ(150px);
}
/* line 46, ../sass/test.scss */
.content .main div:nth-of-type(5) {
background: gray;
transform: rotateY(225deg) translateZ(150px);
}
/* line 46, ../sass/test.scss */
.content .main div:nth-of-type(6) {
background: black;
transform: rotateY(270deg) translateZ(150px);
}
/* line 46, ../sass/test.scss */
.content .main div:nth-of-type(7) {
background: purple;
transform: rotateY(315deg) translateZ(150px);
}
/* line 46, ../sass/test.scss */
.content .main div:nth-of-type(8) {
background: orange;
transform: rotateY(360deg) translateZ(150px);
}
-->
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
 
 
 
 
 
 
 
 
 
$color:red ,yellow ,blue ,green ,gray ,black ,purple ,orange;


@-webkit-keyframes move {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(360deg);
    }
}

body {
    padding: 200px;
    @at-root .content {
        width: 500px;
        height: 500px;
        margin: -350px auto;
        border: 1px solid transparent;
        position: relative;
        -webkit-perspective: 500px;
        -webkit-perspective-origin: center 100px;
        @for $i from 1 to 10 {
            &:nth-of-type(#{$i}) {
                z-index: 10 - $i
            }
        }
        .main {
            width: 100px;
            height: 100px;
            margin: 200px auto;
            position: relative;
            transform-style: preserve-3d;
            animation: move 8s linear infinite;
            div {
                width: 100px;
                height: 100px;
                position: absolute;
                bottom: 0;
                font-size: 100px;
                color: white;
                text-align: center;
                line-height: 100px;
                transform-style: preserve-3d;
                @for $i from 1 to 9 {
                    &:nth-of-type(#{$i}) {
                        background: nth($color, $i);
                        transform: rotateY(45deg * $i) translateZ(150px);
                    }
                }
            }
        }
    }
}
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Examples</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link href="stylesheets/test.css" rel="stylesheet">
</head>

<body>
    <div class="content">
        <div class="main">
            <div>1</div>
            <div>2</div>
            <div>3</div>
            <div>4</div>
            <div>5</div>
            <div>6</div>
            <div>7</div>
            <div>8</div>    
        </div>
    </div>
    <div class="content">
        <div class="main">
            <div>1</div>
            <div>2</div>
            <div>3</div>
            <div>4</div>
            <div>5</div>
            <div>6</div>
            <div>7</div>
            <div>8</div>    
        </div>
    </div>
    <div class="content">
        <div class="main">
            <div>1</div>
            <div>2</div>
            <div>3</div>
            <div>4</div>
            <div>5</div>
            <div>6</div>
            <div>7</div>
            <div>8</div>    
        </div>
    </div>

</body>

</html>

좋은 웹페이지 즐겨찾기