Filter
Exclude
Time range
-
Near
Nowadays, we can do better: ``` box-shadow: 0 1px 2px rgb(from currentcolor r g b/ .65) ``` #tinyCSStip
#tinyCSStip Want the shadow of an element or some other visual to be a semitransparent version of the `currentColor`? Use `color-mix()`!
3
12
250
17,073
Because I often see this and it's a major CSS pet peeve of mine, makes me want to scream "do you even understand what `cover` does?" at the screen every time... #tinyCSStip
4
58
2,741
#tinyCSStip We can have boolean logic in container queries! And this works cross-browser! Live test on @CodePen: codepen.io/thebabydino/pen/Q… #CSS
1
6
87
2,937
#tinyCSStip Want the same border, but only for 2 edges, not for the others? Don't set borders on the 2 edges to the same value. Set border and override border-width. If you later need to make the border thicker/ thinner/ pink/ green, you only need to make that change in 1 place.
2
35
1,277
#tinyCSStip `clip-path` & `mask` are applied after `filter`. This means we can't clip/ mask, then add a `drop-shadow()` on the same element for the clipped/ masked shape. We need to apply the `filter` on a parent of the clipped/ masked (pseudo-)element. codepen.io/thebabydino/pen/B…
1
4
31
4,807
#tinyCSStip Simplifying animations with CSS variables and mathematical functions. Same result, just not writing almost the same `text-shadow` a bunch of times in a bunch of keyframes. Live test on @CodePen: codepen.io/thebabydino/pen/M…
3
16
131
4,388
#tinyCSStip Revert animated parent transform (like a scale or skew) on child without an extra animation using registered custom properties. codepen.io/thebabydino/pen/M…
12
94
4,082
#tinyCSStip 🚫 DON'T use layered text-shadows for text outlines just because text-stroke is broken (x.com/anatudor/status/178848…), they are going to produce ugly corners, thickened roundings and angled lines. βœ… DO: use `paint-order: stroke fill` instead!
Most cursive fonts are unusable with text-stroke. Yeah, there's paint-order, but I want to have a semi-transparent stroke *on top* of the fill in order to create a font-size-relative double stroke, so just covering up the stroke where it intersects the fill defeats that purpose.
1
10
119
5,815
#tinyCSStip Create a fancy double border with dashes in between without any pseudos and with minimal CSS! The relevant code is just 3 simple CSS declarations! Live demo: codepen.io/thebabydino/pen/P…
1
14
653
#tinyCSStip Want to avoid ugly checkerboard edges when pattern size depends on viewport? 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)
1
9
663
#tinyCSStip Pretty sure I've posted about this before, but a quick search at this hour of the morning didn't find it, plus saw someone ask about it yet againΒΉ, so... fixed aspect-ratio box within variable size container! Live on @CodePen codepen.io/thebabydino/pen/o…
1
5
22
1,121
#tinyCSStip Ever want to mask something out of an element, but not cut out blur or box-shadow or a pseudo outside the element's border box? πŸ€” Well, subtract whatever you want masked out from a fully opaque layer with `mask-clip` set to `no-clip`! πŸ’‘
4
8
105
4,953
#tinyCSStip 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!
5
27
1,579
#tinyCSStip Want your page background to contain an integer number of dots? 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 codepen.io/thebabydino/pen/R…
3
13
152
7,558
#tinyCSStip Container queries on the body? Why, when media queries have better support? Well, container queries make it an IF depending on the width of the body's content-box. That is, subtracting the scrollbar IF we have one (we can't know). Live demo codepen.io/thebabydino/pen/Z…
1
7
37
1,670
#tinyCSStip/ fun fact: same aspect ratio is also what we need for a regular hexagon because that can made up of only equilateral triangles! We just need more points for the clip-path (6 for a hexagon vs. 3 for a triangle).
#tinyCSStip Want to create a triangle with all edges equal? Such a triangle also has all vertex angles equal = (sum of angles in a triangle)/3 = 180Β°/3 = 60Β° πŸ‘‰ en.wikipedia.org/wiki/Sum_of… Knowing its edge length a, its height is aΒ·sin(60Β°). Aspect ratio of the box a/(aΒ·sin(60Β°))
1
1
11
922
#tinyCSStip Want to create a triangle with all edges equal? Such a triangle also has all vertex angles equal = (sum of angles in a triangle)/3 = 180Β°/3 = 60Β° πŸ‘‰ en.wikipedia.org/wiki/Sum_of… Knowing its edge length a, its height is aΒ·sin(60Β°). Aspect ratio of the box a/(aΒ·sin(60Β°))
1
6
43
3,238
#tinyCSStip `:is()` is such a great new-ish CSS feature that helps eliminate repetition in selectors ✨
12
75
745
35,206
#tinyCSStip If you don't need the start angle and the sector angle to be decoupled, you can simplify things by making the sector angle depend on the start one. πŸ’‘ 4 base declarations 1 simple animation = magic! πŸͺ„ All pure CSS.

ALT Animated GIF of demo recording. Shows a circle sector rotating around the circle while it grows and shrinks. CSS ``` @property --ini { syntax: '<angle>'; initial-value: 0deg; inherits: false } div.disc1 { --ang: calc(36deg (1 - cos(var(--ini)))*36deg); /* 4 declarations for circle sector */ width: 100%; /* 1 */ aspect-ratio: 1; /* 2 */ border-radius: 50%; /* 3 */ background: /* 4 */ conic-gradient(from var(--ini), lime var(--ang), #0003 0%); /* animation! */ animation: ani 2s linear infinite } @keyframes ani { to { --ini: 1turn } } ```

#tinyCSStip Simplest circle sector in 4 CSS declarations! 1⃣ set width to desired diameter 2⃣ square element with aspect-ratio 3⃣ turn square into disc 4⃣ conic-gradient() magic! πŸͺ„ The start angle and sector angle can also be animated for fun results.
1
2
23
1,936
#tinyCSStip Simplest circle sector in 4 CSS declarations! 1⃣ set width to desired diameter 2⃣ square element with aspect-ratio 3⃣ turn square into disc 4⃣ conic-gradient() magic! πŸͺ„ The start angle and sector angle can also be animated for fun results.
2
2
97
10,517