CSS Snippets
Beautiful box shadows
- soft shadow:
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
CSS Reset
/*
1. Use a more-intuitive box-sizing model.
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
/*
2. Remove default margin
*/
* {
margin: 0;
}
/*
Typographic tweaks!
3. Add accessible line-height
4. Improve text rendering
*/
body {
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
/*
5. Improve media defaults
*/
img,
picture,
video,
canvas,
svg {
display: block;
max-width: 100%;
}
/*
6. Remove built-in form typography styles
*/
input,
button,
textarea,
select {
font: inherit;
}
/*
7. Avoid text overflows
*/
p,
h1,
h2,
h3,
h4,
h5,
h6 {
overflow-wrap: break-word;
}
/*
8. Create a root stacking context
*/
#root,
#__next {
isolation: isolate;
}
Loaders
Skeleton Loaders
Basic Skeleton Loader
Here are the basic styles for skeleton loading utilities:
// skeleton animation class
.animated-bg {
background-image: linear-gradient(
to right,
#f6f7f8 0%,
#edeef1 10%,
#f6f7f8 20%,
#f6f7f8 100%
);
background-size: 200% 100%;
animation: bgPos 1s linear infinite;
}
// component for skeleton text
.animated-bg-text {
border-radius: 50px;
display: inline-block;
height: 0.5rem;
width: 100%;
}
// component for skeleton avatar
.animated-bg-avatar {
border-radius: 9999px;
display: inline-block;
height: 2rem;
width: 2rem;
}
// animation that moves linear gradient
@keyframes bgPos {
0% {
background-position: 50% 0;
}
100% {
background-position: -150% 0;
}
}
THe skeleton animation is based on setting the background color to a grayish linear gradient, and then moving that gradient to the side continously by animating background-position
And here would be an example of HTML using the skeleton loading classes:
<div class="card">
<div class="animated-bg image-container"></div>
<div class="content">
<div class="header">
<div class="animated-bg animated-bg-avatar"></div>
<h3 class="animated-bg animated-bg-text"></h3>
</div>
<div class="body">
<p class="animated-bg animated-bg-text"></p>
<p class="animated-bg animated-bg-text"></p>
<p class="animated-bg animated-bg-text"></p>
</div>
</div>
</div>
Buttons
Gradient buttons
Solid gradient button
.gradient-btn {
--color-1: #ff4545;
--color-2: #00ff99;
--radius: 9999px;
border-radius: var(--radius);
transition: box-shadow 0.25s;
background-image: linear-gradient(
to bottom right,
var(--color-1),
var(--color-2)
);
&:hover {
box-shadow: 40px 0 100px var(--color-1), -40px 0 100px var(--color-2);
}
}