Skip to content

Instantly share code, notes, and snippets.

@CodeMyUI
Created March 10, 2020 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeMyUI/795a1935910d3c69e2d891a2029fd896 to your computer and use it in GitHub Desktop.
Save CodeMyUI/795a1935910d3c69e2d891a2029fd896 to your computer and use it in GitHub Desktop.
Rainbow stacked accordion animation
<link href="https://fonts.googleapis.com/css?family=Archivo+Black&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Archivo:700&display=swap" rel="stylesheet">
<div class="card">
<p>
Similar post
</p>
<h2>
How I recreated a Polaroid camera with CSS gradients only
</h2>
</div>

Rainbow stacked accordion animation

Outcome of a box-shadow tutorial that will soon get published on fossheim.io (early access through Patreon).

A Pen by Sarah Fossheim on CodePen.

License.

.card {
background-color: var(--background);
display: block;
width: 300px;
min-height: 90px;
border: 3px solid var(--primary);
padding: 15px;
margin: calc(50vh - 30px) auto 0 auto;
box-shadow: 10px -10px 0 -3px var(--background), 10px -10px var(--green),
20px -20px 0 -3px var(--background), 20px -20px var(--yellow),
30px -30px 0 -3px var(--background), 30px -30px var(--orange),
40px -40px 0 -3px var(--background), 40px -40px var(--red);
transition: box-shadow 1s, top 1s, left 1s;
position: relative;
top: 0;
left: 0;
cursor: pointer;
}
.card:hover {
top: -40px;
left: 40px;
box-shadow: 0 0 0 -3px var(--background), 0 0 0 0 var(--green),
0 0 0 -3px var(--background), 0 0 0 0 var(--yellow),
0 0 0 -3px var(--background), 0 0 0 0 var(--orange),
0 0 0 -3px var(--background), 0 0 0 0 var(--red);
}
:root {
--primary: #555BFF;
--secondary: #22D2A0;
--background: white;
--green: #1FC11B;
--yellow: #FFD913;
--orange: #FF9C55;
--red: #FF5555;
}
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
background-image: radial-gradient(var(--secondary) 30%, var(--background) 30%);
background-size: 2px 3px;
font-family: "Archivo", sans-serif;
color: var(--primary);
}
.card p {
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: 10px;
}
.card h2 {
font-size: 14px;
font-family: "Archivo Black", "Archivo", sans-serif;
font-weight: normal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment