Skip to content

Instantly share code, notes, and snippets.

View LeaVerou's full-sized avatar

Lea Verou LeaVerou

View GitHub Profile
@LeaVerou
LeaVerou / dabblet.css
Last active April 24, 2024 17:41
Polar interpolation issues
/**
* Polar interpolation issues
*/
div {
padding: 2em;
flex: 1;
}
div:nth-of-type(1) {
@LeaVerou
LeaVerou / dabblet.css
Last active April 24, 2024 17:40
Polar interpolation discontinuity
/**
* Polar interpolation discontinuity
*/
div:nth-of-type(1) {
background: linear-gradient(to right in oklch, oklch(70% 0.1 0), oklch(70% 0.1 180));
}
div:nth-of-type(2) {
background: linear-gradient(to right in oklch, oklch(70% 0.1 0), oklch(70% 0.1 179));
@LeaVerou
LeaVerou / dabblet.css
Last active April 24, 2024 17:31
none-containing values as intermediate stops
/**
* none-containing values as intermediate stops
*/
div:nth-of-type(1) {
background: linear-gradient(to right in oklch, oklch(80% 0.1 0), oklch(80% 0.1 170));
}
div:nth-of-type(2) {
background: linear-gradient(to right in oklch, oklch(80% 0.1 0), oklch(50% none none), oklch(80% 0.1 170));

Custom coord types

let turquoise = new Color("oklch(.7 .1 180)");

// Custom functional format:
turquoise.toString({format: {
	name: "oklch",
	coords: [
@LeaVerou
LeaVerou / dabblet.css
Last active March 28, 2024 06:22
Two column <dl> with two lines of CSS! Thank you Grid Layout!
/**
* Two column <dl> with two lines of CSS! Thank you Grid Layout!
* Limitation: Breaks if we have multiple consecutive <dt>s or <dd>s
*/
dl {
display: grid;
grid-template: auto / 10em 1fr;
}
@LeaVerou
LeaVerou / vunits.js
Created November 8, 2011 11:05
Static polyfill for vw, vh, vm units
/**
* Polyfill for the vw, vh, vm units
* Requires StyleFix from -prefix-free http://leaverou.github.com/prefixfree/
* @author Lea Verou
*/
(function() {
if(!window.StyleFix) {
return;
@LeaVerou
LeaVerou / dabblet.css
Created April 19, 2013 21:19
SVG inspired by Quine's paradox
/**
* SVG inspired by Quine's paradox
*/
svg {
display: block;
margin: 40px auto;
font: 83px sans-serif;
}
@LeaVerou
LeaVerou / dabblet.css
Created November 29, 2023 18:26
keyword + <percentage> in <position>
/**
* keyword + <percentage> in <position>
*/
background: linear-gradient(45deg, #f06, yellow) no-repeat left 10% / 1em 1em;
min-height: 100vh;
@LeaVerou
LeaVerou / dabblet.css
Last active October 9, 2023 01:48
none keyword test
/**
* none keyword test
* Pass: There should be no red, nor any distinct squares
*/
html {
background: red; /* if you see this, the none keyword is not supported */
background: color-mix(in hsl, hsl(80 50% 90%) 0%, hsl(none none 50%));
}
@LeaVerou
LeaVerou / dabblet.css
Last active September 20, 2023 08:11
Move in a circle without wrapper elements
/**
* Move in a circle without wrapper elements
* Idea by Aryeh Gregor, simplified by Lea Verou
*/
@keyframes rot {
from {
transform: rotate(0deg)
translate(-150px)
rotate(0deg);