```
box-shadow: 0 1px 2px
rgb(from currentcolor r g b/ .65)
```
Cross-browser since September 2024.
#tinyCSStip #CSS
Want the shadow of an element or some other visual to be a semitransparent version of the `currentColor`?
Use `color-mix()`!
Cross-browser, btw. 😼
```
box-shadow: 0 1px 2px
rgb(from currentcolor r g b/ .65)
```
Cross-browser since September 2024.
#tinyCSStip #CSS
Use `background-repeat: space`! This inserts a bit of space in between background repetitions so we have an integer number of them. Well-supported for ages. 🥳
Live on @codepen.io codepen.io/thebabydino/...
#CSS #pattern
Use `background-repeat: space`! This inserts a bit of space in between background repetitions so we have an integer number of them. Well-supported for ages. 🥳
Live on @codepen.io codepen.io/thebabydino/...
#CSS #pattern
`:is()` is such a great new-ish #CSS feature that helps eliminate repetition in selectors ✨
`:is()` is such a great new-ish #CSS feature that helps eliminate repetition in selectors ✨
I like shorthands, I find them immensely useful. But it doesn't always make sense to drop it all in the shorthand and having repetitions. Yeah, you can store that `.2s` in a #CSS variable. But is it really worth it if you're not even using it elsewhere in addition to not being dynamic?
I like shorthands, I find them immensely useful. But it doesn't always make sense to drop it all in the shorthand and having repetitions. Yeah, you can store that `.2s` in a #CSS variable. But is it really worth it if you're not even using it elsewhere in addition to not being dynamic?
Pretty sure I've posted about this before, but a quick search at this hour didn't find it, plus saw someone ask about it yet again¹, so... fixed aspect-ratio box within variable size container!
Live on @codepen.io codepen.io/thebabydino/...
¹here www.reddit.com/r/css/commen...
#CSS
Pretty sure I've posted about this before, but a quick search at this hour didn't find it, plus saw someone ask about it yet again¹, so... fixed aspect-ratio box within variable size container!
Live on @codepen.io codepen.io/thebabydino/...
¹here www.reddit.com/r/css/commen...
#CSS
And this works cross-browser!
Live test on @codepen.io: codepen.io/thebabydino/...
More info on @developer.mozilla.org: developer.mozilla.org/en-US/docs/W...
#CSS
And this works cross-browser!
Live test on @codepen.io: codepen.io/thebabydino/...
More info on @developer.mozilla.org: developer.mozilla.org/en-US/docs/W...
#CSS
Sometimes, if you notice a teeny tiny misalignment and you cannot understand why because *nothing* in your CSS looks like it could have caused it... try using `round()` to round to an integer number of pixels.
It just solved my own tiny misalignment problem that was driving me batty. 🦇
Sometimes, if you notice a teeny tiny misalignment and you cannot understand why because *nothing* in your CSS looks like it could have caused it... try using `round()` to round to an integer number of pixels.
It just solved my own tiny misalignment problem that was driving me batty. 🦇
Want the shadow of an element or some other visual to be a semitransparent version of the `currentColor`, which was given as a hex or keyword value?
No need to convert to rgb() or hsl() anymore!
#CSS
Want the shadow of an element or some other visual to be a semitransparent version of the `currentColor`, which was given as a hex or keyword value?
No need to convert to rgb() or hsl() anymore!
#CSS
```
.item { counter-increment: c }
.item::after { content: counter(c, upper-alpha) }
```
#tinyCSStip
```
.item { counter-increment: c }
.item::after { content: counter(c, upper-alpha) }
```
#tinyCSStip
Range input browser inconsistencies may mean needing different styles for different browsers. Possible for track & thumb via different pseudos, but what about the actual range input?
Well, `@supports selector()` to the rescue!
Live test on @codepen.io codepen.io/thebabydino/...
#CSS
Range input browser inconsistencies may mean needing different styles for different browsers. Possible for track & thumb via different pseudos, but what about the actual range input?
Well, `@supports selector()` to the rescue!
Live test on @codepen.io codepen.io/thebabydino/...
#CSS
How varying clip-path: inset() from the right element edge can help with a left to right reveal effect
✨ when this inset is 100%, all gets cut off
✨ when this inset is 0%, nothing gets cut off
Interactive illustration codepen.io/thebabydino/... + 🆒 pure #CSS on scroll use case 👇
How varying clip-path: inset() from the right element edge can help with a left to right reveal effect
✨ when this inset is 100%, all gets cut off
✨ when this inset is 0%, nothing gets cut off
Interactive illustration codepen.io/thebabydino/... + 🆒 pure #CSS on scroll use case 👇
`:has()` fixes this problem.
`:not(:has(*))` selects elements that don't have element children, even if they have text content.
`:has()` fixes this problem.
`:not(:has(*))` selects elements that don't have element children, even if they have text content.
The relevant code is just 3 simple CSS declarations!
Live demo on @codepen.io: codepen.io/thebabydino/...
The relevant code is just 3 simple CSS declarations!
Live demo on @codepen.io: codepen.io/thebabydino/...
❌ DON'T 🙀
width: 100%; height: 100%;
left: 50%; top: 50%;
translate: -50% -50%;
padding: 8px
✅ DO 😼 (1 declaration, not 6)
inset: -8px
#CSS
❌ DON'T 🙀
width: 100%; height: 100%;
left: 50%; top: 50%;
translate: -50% -50%;
padding: 8px
✅ DO 😼 (1 declaration, not 6)
inset: -8px
#CSS
Round it to be a multiple of 2px so every square edge is an int number of pixels!
--s: round(10vmin, 2px);
background:
repeating-conic-gradient(red 0% 25%, tan 0% 50%)
0 0/ var(--s) var(--s)
#CSS
Round it to be a multiple of 2px so every square edge is an int number of pixels!
--s: round(10vmin, 2px);
background:
repeating-conic-gradient(red 0% 25%, tan 0% 50%)
0 0/ var(--s) var(--s)
#CSS
(love grid for stacking/ full coverage too, but there are differences between how the two solutions work and there are cases when absolute positioning is still preferable)
#CSS
(love grid for stacking/ full coverage too, but there are differences between how the two solutions work and there are cases when absolute positioning is still preferable)
#CSS
Revert animated parent transform (like a scale or skew) on child without an extra animation using registered custom properties.
codepen.io/thebabydino/...
#CSS
Revert animated parent transform (like a scale or skew) on child without an extra animation using registered custom properties.
codepen.io/thebabydino/...
#CSS
#CSS
#CSS
#tinyCSStip
#tinyCSStip
Same result, just not writing almost the same `text-shadow` a bunch of times in a bunch of keyframes.
Live test on @codepen.io: codepen.io/thebabydino/...
#CSS #Maths
Same result, just not writing almost the same `text-shadow` a bunch of times in a bunch of keyframes.
Live test on @codepen.io: codepen.io/thebabydino/...
#CSS #Maths
❌ DON'T 😬
orange 40%, hotpink 0, hotpink 60%, purple 0
✅ DO 😎
orange 40%, hotpink 0 60%, purple 0
Also see:
codepen.io/thebabydino/...
#CSS
❌ DON'T 😬
orange 40%, hotpink 0, hotpink 60%, purple 0
✅ DO 😎
orange 40%, hotpink 0 60%, purple 0
Also see:
codepen.io/thebabydino/...
#CSS
So you have a responsive, flexible `width` rectangular box with `aspect-ratio: 2` and want to turn it into a half disc?
Use a `50%` horizontal `border-radius` and a vertical one that's `100%` for the top corners (first two listed) and `0` for the other two!
So you have a responsive, flexible `width` rectangular box with `aspect-ratio: 2` and want to turn it into a half disc?
Use a `50%` horizontal `border-radius` and a vertical one that's `100%` for the top corners (first two listed) and `0` for the other two!
Test
codepen.io/thebabydino/...
(without hint, with hint, difference)
What MDN says
developer.mozilla.org/en-US/docs/W...
Test
codepen.io/thebabydino/...
(without hint, with hint, difference)
What MDN says
developer.mozilla.org/en-US/docs/W...
(interactive codepen.io/thebabydino/...)
#tinyCSStip there's a workaround IF corner radius ≤ border-width: use inset() clip-path + a round value!
clip-path: inset(0 round $r)
@codepen.io demo: codepen.io/thebabydino/...
#CSS
(interactive codepen.io/thebabydino/...)
#tinyCSStip there's a workaround IF corner radius ≤ border-width: use inset() clip-path + a round value!
clip-path: inset(0 round $r)
@codepen.io demo: codepen.io/thebabydino/...
#CSS
❌ DON'T (blurry edge for big background-size, jagged edge for small background-size)
radial-gradient(at 0 100%, #000 69%, #0000 70%)
✅ DO (smooth edge regardless of background-size)
radial-gradient(at 0 100%, #000 calc(70% - 1px), #0000 70%)
❌ DON'T (blurry edge for big background-size, jagged edge for small background-size)
radial-gradient(at 0 100%, #000 69%, #0000 70%)
✅ DO (smooth edge regardless of background-size)
radial-gradient(at 0 100%, #000 calc(70% - 1px), #0000 70%)