Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# css_effect
# 3D Text Cube Animation Effects

View and try [DEMO](https://codepen.io/filippoerbisti/pen/PoQJKyd) on Codepen.
39 changes: 39 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Text Cube Animation Effects</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="text" style="--j:0">
<span style="--i:0">2</span>
<span style="--i:1">3</span>
<span style="--i:2">4</span>
<span style="--i:3">5</span>
</div>
<div class="text" style="--j:1">
<span style="--i:0">0</span>
<span style="--i:1">1</span>
<span style="--i:2">2</span>
<span style="--i:3">3</span>
</div>
<div class="text" style="--j:2">
<span style="--i:0">2</span>
<span style="--i:1">3</span>
<span style="--i:2">4</span>
<span style="--i:3">5</span>
</div>
<div class="text" style="--j:3">
<span style="--i:0">2</span>
<span style="--i:1">3</span>
<span style="--i:2">4</span>
<span style="--i:3">5</span>
</div>
</div>

</body>
</html>
77 changes: 77 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&display=swap');

* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Oswald', sans-serif;
}

body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #3d3d3d;
}

.container {
display: flex;
transform-style: preserve-3d;
gap: 10px;
transform: rotateY(30deg) rotateX(10deg);
}

.container .text {
position: relative;
width: 100px;
height: 100px;
transform-style: preserve-3d;
transition: 2.5s ease-in-out;
transition-delay: calc(0.25s * var(--j));
}

.container:hover .text {
transform: rotateX(360deg);


}

.container:hover .text:last-child {
transform: rotateX(630deg);
}

.container .text::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
background: #373737;
transform-origin: left;
transform: rotateY(90deg) translateX(-50px);
}

.container .text:last-child:before {
background: #29ab3c;
}

.container .text span {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(#434343, #535353);
display: flex;
align-items: center;
justify-content: center;
font-size: 4em;
color: #fff;
transform-style: preserve-3d;
transform: rotateX(calc(90deg * var(--i))) translateZ(50px);
}

.container .text:last-child span {
background: linear-gradient(#29c040, #32ed4e);
color: #333;
}