File tree Expand file tree Collapse file tree 5 files changed +120
-1
lines changed
Expand file tree Collapse file tree 5 files changed +120
-1
lines changed Original file line number Diff line number Diff line change 44 "[scss]" : {
55 "editor.defaultFormatter" : " vscode.css-language-features"
66 }
7- }
7+ }
Original file line number Diff line number Diff line change 1+ [ Web.dev Blog Link] ( https://dev.to/martinp/how-to-do-stunning-3d-with-pure-htmlcss-ah )
2+
3+ [ perspective MDN Doc Link] ( https://developer.mozilla.org/en-US/docs/Web/CSS/perspective )
4+
5+ [ transform-style MDN Doc Link] ( https://developer.mozilla.org/en-US/docs/Web/CSS/transform-style )
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < link rel ="stylesheet " href ="style.css ">
7+ < title > 3D Animation</ title >
8+ </ head >
9+ < body >
10+ < div class ="perspective ">
11+ < div class ="box ">
12+ < div class ="face top "> </ div >
13+ < div class ="face bottom "> </ div >
14+ < div class ="face back "> </ div >
15+ < div class ="face front "> </ div >
16+ < div class ="face left "> </ div >
17+ < div class ="face right "> </ div >
18+ </ div >
19+ </ div >
20+ </ body >
21+ </ html >
Original file line number Diff line number Diff line change 1+ * {
2+ margin : 0 ;
3+ padding : 0 ;
4+ box-sizing : border-box;
5+ }
6+
7+ body {
8+ width : 100% ;
9+ height : 100vh ;
10+ display : grid;
11+ place-items : center;
12+ background-color : black;
13+ }
14+
15+ : root {
16+ --size : 100px ;
17+ }
18+
19+ .perspective {
20+ position : relative;
21+ perspective : 800px ;
22+ perspective-origin : 50% -200px ;
23+ }
24+
25+ .box {
26+ width : var (--size );
27+ aspect-ratio : 1 ;
28+
29+ position : relative;
30+ transform-style : preserve-3d;
31+
32+ transform-origin : 50px bottom -50px ;
33+ animation : rotate 4s linear infinite;
34+ }
35+
36+ .face {
37+ position : absolute;
38+ width : var (--size );
39+ aspect-ratio : 1 ;
40+
41+ transform-style : preserve-3d;
42+ background-color : hsl (39 , 100% , var (--lightness ));
43+ }
44+
45+ .face .front {
46+ --lightness : 66% ;
47+ }
48+
49+ .face .bottom {
50+ --lightness : 74% ;
51+ top : 100% ;
52+ transform-origin : top;
53+ transform : rotateX (-90deg );
54+ }
55+
56+ .face .top {
57+ --lightness : 74% ;
58+ bottom : 100% ;
59+ transform-origin : bottom;
60+ transform : rotateX (90deg );
61+ }
62+
63+ .face .back {
64+ --lightness : 78% ;
65+ bottom : 200% ;
66+ transform-origin : center 150px -50px ;
67+ transform : rotateX (180deg );
68+ }
69+
70+ .face .right {
71+ --lightness : 70% ;
72+ left : 100% ;
73+ transform-origin : left;
74+ transform : rotateY (90deg );
75+ }
76+
77+ .face .left {
78+ --lightness : 70% ;
79+ right : 100% ;
80+ transform-origin : right;
81+ transform : rotateY (-90deg );
82+ }
83+
84+ @keyframes rotate {
85+ from {
86+ transform : rotate (0 );
87+ }
88+
89+ to {
90+ transform : rotateY (360deg );
91+ }
92+ }
Original file line number Diff line number Diff line change 5454 < a href ="./Scratch card effect/demo.html "> Scratch card effect</ a >
5555 < a href ="./Image Sprites/demo.html "> Image Sprites</ a >
5656 < a href ="./BEM(Block, Element Modifier)/demo.html "> BEM(Block, Element Modifier)</ a >
57+ < a href ="./3D animation/demo.html "> 3D Animation</ a >
5758</ body >
5859
5960</ html >
You can’t perform that action at this time.
0 commit comments