animated grid boxes project from YT
This commit is contained in:
parent
ed604c1e64
commit
7a6c0a5b66
|
@ -0,0 +1,38 @@
|
||||||
|
<!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">
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
<title>Animated Grid Boxes</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>Animated Grid Boxes</h1>
|
||||||
|
<p>Code from https://fireship.io/lessons/three-responsive-css-grid-layouts/ + change based on comment that
|
||||||
|
simplifies the css down to one rule, but puts some of the info into the html to mark each div with variables
|
||||||
|
for the animiation delay (--i) and the name of the box's grid space (--g)</p>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<section class="animated-grid">
|
||||||
|
<div style="--i: 1; --g: a;" class="card">a</div>
|
||||||
|
<div style="--i: 2; --g: b;" class="card">b</div>
|
||||||
|
<div style="--i: 3; --g: c;" class="card">c</div>
|
||||||
|
<div style="--i: 4; --g: d;" class="card">d</div>
|
||||||
|
<div style="--i: 5; --g: e;" class="card">e</div>
|
||||||
|
<div style="--i: 6; --g: f;" class="card">f</div>
|
||||||
|
<div style="--i: 7; --g: g;" class="card">g</div>
|
||||||
|
<div style="--i: 8; --g: h;" class="card">h</div>
|
||||||
|
<div style="--i: 9; --g: i;" class="card">i</div>
|
||||||
|
<div style="--i: 10; --g: j;" class="card">j</div>
|
||||||
|
<div style="--i: 11; --g: k;" class="card">k</div>
|
||||||
|
<div style="--i: 12; --g: l;" class="card">l</div>
|
||||||
|
<div style="--i: 13; --g: 🌟;" class="card">main</div>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -0,0 +1,139 @@
|
||||||
|
/* // BASE */
|
||||||
|
body {
|
||||||
|
background: rgb(18, 18, 18);
|
||||||
|
color: hsl(0, 0%, 100%);
|
||||||
|
font-family: "Noto Sans", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
background: hsl(0, 0%, 21%);
|
||||||
|
font-size: 3rem;
|
||||||
|
color: hsl(0, 0%, 100%);
|
||||||
|
box-shadow: rgba(3, 8, 20, 0.1) 0px 0.15rem 0.5rem,
|
||||||
|
rgba(2, 8, 20, 0.1) 0px 0.075rem 0.175rem;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: all 500ms;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card:hover {
|
||||||
|
box-shadow: rgba(2, 7, 19, 0.1) 0px 0.35em 1.175em,
|
||||||
|
rgba(2, 8, 20, 0.08) 0px 0.175em 0.5em;
|
||||||
|
transform: translateY(-3px) scale(1.1);
|
||||||
|
background-color: hsl(152, 90%, 75%);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Specifics */
|
||||||
|
.animated-grid {
|
||||||
|
height: 85vh;
|
||||||
|
margin-bottom: 200px;
|
||||||
|
|
||||||
|
display: grid;
|
||||||
|
gap: 1rem;
|
||||||
|
|
||||||
|
/* Explicit grid */
|
||||||
|
grid-template-areas:
|
||||||
|
"a b c d"
|
||||||
|
"l 🌟 🌟 e"
|
||||||
|
"k 🌟 🌟 f"
|
||||||
|
"j i h g";
|
||||||
|
|
||||||
|
grid-template-rows: repeat(4, 25%);
|
||||||
|
grid-template-columns: 240px auto auto 240px;
|
||||||
|
|
||||||
|
--stagger-delay: 100ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes cardEntrance {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale(0.3);
|
||||||
|
filter: hue-rotate(180deg);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: scale(1);
|
||||||
|
filter: hue-rotate(0deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
background-color: hsl(152, 90%, 55%);
|
||||||
|
animation: cardEntrance 700ms ease-out;
|
||||||
|
animation-fill-mode: backwards;
|
||||||
|
grid-area: var(--g);
|
||||||
|
animation-delay: calc(var(--i) * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .card {
|
||||||
|
background-color: rgb(36, 243, 147);
|
||||||
|
animation: cardEntrance 700ms ease-out;
|
||||||
|
animation-fill-mode: backwards;
|
||||||
|
} */
|
||||||
|
|
||||||
|
/* .card:nth-child(1) {
|
||||||
|
grid-area: a;
|
||||||
|
animation-delay: calc(1 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:nth-child(2) {
|
||||||
|
grid-area: b;
|
||||||
|
animation-delay: calc(2 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:nth-child(3) {
|
||||||
|
grid-area: c;
|
||||||
|
animation-delay: calc(3 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:nth-child(4) {
|
||||||
|
grid-area: d;
|
||||||
|
animation-delay: calc(4 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:nth-child(5) {
|
||||||
|
grid-area: e;
|
||||||
|
animation-delay: calc(5 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:nth-child(6) {
|
||||||
|
grid-area: f;
|
||||||
|
animation-delay: calc(6 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:nth-child(7) {
|
||||||
|
grid-area: g;
|
||||||
|
animation-delay: calc(7 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:nth-child(8) {
|
||||||
|
grid-area: h;
|
||||||
|
animation-delay: calc(8 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:nth-child(9) {
|
||||||
|
grid-area: i;
|
||||||
|
animation-delay: calc(9 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:nth-child(10) {
|
||||||
|
grid-area: j;
|
||||||
|
animation-delay: calc(10 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:nth-child(11) {
|
||||||
|
grid-area: k;
|
||||||
|
animation-delay: calc(11 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:nth-child(12) {
|
||||||
|
grid-area: l;
|
||||||
|
animation-delay: calc(12 * var(--stagger-delay));
|
||||||
|
}
|
||||||
|
.card:last-child {
|
||||||
|
grid-area: 🌟;
|
||||||
|
animation-delay: calc(13 * var(--stagger-delay));
|
||||||
|
} */
|
Loading…
Reference in New Issue