Skip to content

Instantly share code, notes, and snippets.

@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 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 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 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
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 September 3, 2022 09:58
Vertical centering - Flexbox solution
/**
* Vertical centering - Flexbox solution
*/
* { margin: 0 }
body {
display: flex;
min-height: 100vh;
}
@csssecrets
csssecrets / dabblet.css
Created November 13, 2014 11:57
Vertical centering - Flexbox solution for text
/**
* Vertical centering - Flexbox solution for text
*/
body {
display: flex;
align-items: center;
min-height: 100%;
margin: 0;
}
@csssecrets
csssecrets / dabblet.css
Last active October 3, 2021 17:05
Sticky footer with fixed height
/**
* Sticky footer with fixed height
*/
main {
min-height: calc(100vh - 5em - 7em);
}
/* Toggle checkbox to alternate between short/long content */
#contents:checked ~ p { display: none }
@csssecrets
csssecrets / dabblet.css
Last active November 8, 2021 14:01
Sticky footer with flexible height
/**
* Sticky footer with flexible height
*/
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
@csssecrets
csssecrets / dabblet.css
Last active July 11, 2022 06:59
Intrinsic sizing
/**
* Intrinsic sizing
*/
figure {
max-width: 300px;
max-width: min-content;
margin: auto;
}