1
+ .parent {
2
+ background : lightgray;
3
+ font-family : sans-serif;
4
+ color : # fefefe ;
5
+ height : 100vh ;
6
+ overflow : hidden;
7
+ }
8
+ .container {
9
+ position : relative;
10
+ width : 320px ;
11
+ margin : 100px auto 0 auto;
12
+ perspective : 1000px ;
13
+ }
14
+
15
+ .carousel {
16
+ position : absolute;
17
+ width : 100% ;
18
+ height : 100% ;
19
+ transform-style : preserve-3d;
20
+ animation : rotate360 60s infinite forwards linear;
21
+ }
22
+ .carousel__face {
23
+ position : absolute;
24
+ width : 300px ;
25
+ height : 187px ;
26
+ top : 20px ;
27
+ left : 10px ;
28
+ right : 10px ;
29
+ background-size : cover;
30
+ box-shadow : inset 0 0 0 2000px rgba (0 , 0 , 0 , 0.5 );
31
+ display : flex;
32
+ }
33
+
34
+ span {
35
+ margin : auto;
36
+ font-size : 2rem ;
37
+ }
38
+
39
+ .carousel__face : nth-child (1 ){
40
+ background-image : url ("https://images.pexels.com/photos/1141853/pexels-photo-1141853.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" );
41
+ transform : rotateY ( 0deg ) translateZ (430px );
42
+ }
43
+ .carousel__face : nth-child (2 ){
44
+ background-image : url ("https://images.pexels.com/photos/1258865/pexels-photo-1258865.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" );
45
+ transform : rotateY ( 40deg ) translateZ (430px );
46
+ }
47
+ .carousel__face : nth-child (3 ){
48
+ background-image : url ("https://images.pexels.com/photos/808466/pexels-photo-808466.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" );
49
+ transform : rotateY ( 80deg ) translateZ (430px );
50
+ }
51
+ .carousel__face : nth-child (4 ){
52
+ background-image : url ("https://images.pexels.com/photos/1394841/pexels-photo-1394841.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" );
53
+ transform : rotateY (120deg ) translateZ (430px );
54
+ }
55
+ .carousel__face : nth-child (5 ){
56
+ background-image : url ("https://images.pexels.com/photos/1141853/pexels-photo-1141853.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" );
57
+ transform : rotateY (160deg ) translateZ (430px );
58
+ }
59
+ .carousel__face : nth-child (6 ){
60
+ background-image : url ("https://images.pexels.com/photos/1834400/pexels-photo-1834400.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" );
61
+ transform : rotateY (200deg ) translateZ (430px );
62
+ }
63
+ .carousel__face : nth-child (7 ){
64
+ background-image : url ("https://images.pexels.com/photos/1415268/pexels-photo-1415268.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" );
65
+ transform : rotateY (240deg ) translateZ (430px );
66
+ }
67
+ .carousel__face : nth-child (8 ){
68
+ background-image : url ("https://images.pexels.com/photos/135018/pexels-photo-135018.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" );
69
+ transform : rotateY (280deg ) translateZ (430px );
70
+ }
71
+ .carousel__face : nth-child (9 ){
72
+ background-image : url ("https://images.pexels.com/photos/1175135/pexels-photo-1175135.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" );
73
+ transform : rotateY (320deg ) translateZ (430px );
74
+ }
75
+
76
+
77
+ @keyframes rotate360 {
78
+ from {
79
+ transform : rotateY (0deg );
80
+ }
81
+ to {
82
+ transform : rotateY (-360deg );
83
+ }
84
+ }
0 commit comments