Skip to content

Instantly share code, notes, and snippets.

@csssecrets
csssecrets / dabblet.css
Created November 13, 2014 10:54
Vertical centering - Viewport unit method
/**
* Vertical centering - Viewport unit method
*/
main {
width: 18em;
padding: 1em 1.5em;
margin: 50vh auto 0;
transform: translateY(-50%);
box-sizing: border-box;
@csssecrets
csssecrets / dabblet.css
Last active July 24, 2023 08:35
Vertical centering - absolute positioning method
/**
* Vertical centering - absolute positioning method
*/
main {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
@csssecrets
csssecrets / dabblet.css
Last active October 3, 2021 16:53
Fluid background, fixed content
/**
* Fluid background, fixed content
*/
header, section, footer {
padding: 1em calc(50% - 350px);
}
footer {
background: #333;
@csssecrets
csssecrets / dabblet.css
Last active September 30, 2021 21:35
Styling by sibling count: Color palette example
/**
* Styling by sibling count: Color palette example
*/
/* Hide "color" 4 items or more */
.palette li:first-child:nth-last-child(n+4) .color-options a:after,
.palette li:first-child:nth-last-child(n+4) ~ li .color-options a:after {
content: none;
}
@csssecrets
csssecrets / dabblet.css
Last active October 10, 2021 14:56
Animation along a circular path - Solution 2
/**
* Animation along a circular path - Solution 2
*/
@keyframes spin {
from {
transform: rotate(0turn)
translateY(-150px) translateY(50%)
rotate(1turn)
}
@csssecrets
csssecrets / dabblet.css
Last active October 10, 2021 15:26
Animation along a circular path - Solution 1
/**
* Animation along a circular path - Solution 1
*/
@keyframes spin {
to { transform: rotate(1turn); }
}
.avatar {
animation: spin 3s infinite linear;
@csssecrets
csssecrets / dabblet.css
Created October 6, 2014 09:35
Smooth state animations
/**
* Smooth state animations
* Photo credits: https://www.flickr.com/photos/employtheskinnyboy/3904743709
*/
@keyframes panoramic {
to { background-position: 100% 0; }
}
.panoramic {
@csssecrets
csssecrets / dabblet.css
Created October 6, 2014 01:38
Typing animation
/**
* Typing animation
*/
@keyframes typing {
from { width: 0 }
}
@keyframes caret {
50% { border-right-color: transparent; }
@csssecrets
csssecrets / dabblet.css
Created September 29, 2014 04:58
Blinking
/**
* Blinking
*/
@keyframes blink-1 { 50% { color: transparent } }
@keyframes blink-2 { to { color: transparent } }
p {
padding: 1em;
background: gold;
@csssecrets
csssecrets / dabblet.css
Last active October 3, 2021 17:46
Frame-by-frame animations
/**
* Frame-by-frame animations
*/
@keyframes loader {
to { background-position: -800px 0; }
}
.loader {
width: 100px; height: 100px;