Skip to content

Instantly share code, notes, and snippets.

@csssecrets
csssecrets / dabblet.css
Created January 4, 2015 21:58
Flexible background positioning
/**
* Flexible background positioning
* via extended background-position
*/
div {
background: url(http://csssecrets.io/images/code-pirate.svg)
no-repeat bottom right #58a;
background-origin: content-box;
@csssecrets
csssecrets / dabblet.css
Last active April 22, 2022 12:21
Flexible background positioning
/**
* Flexible background positioning
* via extended background-position
*/
div {
background: url(http://csssecrets.io/images/code-pirate.svg)
no-repeat bottom right #58a;
background-position: right 20px bottom 10px;
@csssecrets
csssecrets / dabblet.css
Created January 4, 2015 19:33
Multiple borders
/**
* Multiple borders
*/
div {
width: 100px;
height: 60px;
margin: 25px;
background: yellowgreen;
box-shadow: 0 0 0 10px #655,
@csssecrets
csssecrets / dabblet.css
Created January 4, 2015 15:17
Translucent borders
/**
* Translucent borders
*/
body {
background: url('http://csssecrets.io/images/stone-art.jpg');
}
div {
border: 10px solid hsla(0,0%,100%,.5);
@csssecrets
csssecrets / dabblet.css
Last active September 30, 2021 21:35
Taming table column widths
/**
* Taming table column widths
*/
body { background: #ddd }
section {
width: 500px;
margin: 2em;
background: white;
@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;
}
@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 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
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 September 3, 2022 09:58
Vertical centering - Flexbox solution
/**
* Vertical centering - Flexbox solution
*/
* { margin: 0 }
body {
display: flex;
min-height: 100vh;
}