Advertisement ยท 728 ร— 90

Posts by Robey Lawrence

CSS code snippet:

.magic {
  --bg: red;
  background: var(--bg);
  /* Swap between white or black based on the background. */
  color: lch(from var(--bg) calc((50 - l) * infinity) 0 0);
}

CSS code snippet: .magic { --bg: red; background: var(--bg); /* Swap between white or black based on the background. */ color: lch(from var(--bg) calc((50 - l) * infinity) 0 0); }

Found a neat CSS trick to automatically swap between black or white text based on any arbitrary background color!

With relative color syntax, you can use calc to adjust the text color depending if the background is above or below 50% lightness in the LCH color space.

1 year ago 442 56 14 11

๐Ÿ˜‚

1 year ago 0 0 0 0

Awesome!
High five ๐Ÿ™Œ

1 year ago 2 0 0 0

๐Ÿ˜‚๐Ÿ‹

1 year ago 0 0 0 0

Bon Iver is nice on a quiet weekend morning.

1 year ago 1 0 0 0
Post image

Every year..

1 year ago 0 0 0 0

Sucked on a lemon?

1 year ago 0 0 1 0
Advertisement
Post image Post image Post image Post image

2024 Music Recap

1 year ago 2 0 1 0