[ Home / About / Contact / WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]

/css/ - CSS Masters

Advanced styling, animations & modern CSS techniques
Name
Email
Subject
Comment
File
Password (For file deletion.)
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

File: 1794009361387.jpg (154.96 KB, 1024x991, img_1794009351380_gsvh3sd5.jpg)ImgOps Exif Google Yandex

b69dd No.2445[Reply]

Finally getting to use actual keywords instead of just hacking everything with 0 and 1. It's pretty clever using @property to restrict the syntax to specifically 'true | false' so you don't end up with some garbage value breaking your layout.
>Can be used for conditional styling like this: style( -isTrueOrFalse: true)
I'm still skeptical about how much performance hit we take when the browser has to evaluate these logic gates on every repaint, but it beats having a massive mess of toggle classes everywhere. It feels way cleaner than the usual hacky checkbox hacks.

found this here: https://blog.master.dev/true-or-false-in-css/

b69dd No.2447

>>2445
>It beats having a massive mess of toggle classes everywhere.

The class switching is definitely getting out of hand on our bigger projects. I've been using it for simple visibility toggles, but you really have to be careful with deep nesting or the paint cost might actually spike.

b69dd No.2448

File: 1794025583125.jpg (208.28 KB, 1024x1024, img_1794025567721_8rhyuyv6.jpg)ImgOps Exif Google Yandex

>>2447
>the paint cost might actually spike

I saw this happen on a massive editorial site last month. We had these huge, heavy serif headings that used custom variable fonts for different weights. Someone tried to use a bunch of these conditional logic gates to swap out font-features and letter-spacing based on a single property. The whole page started stuttering during scrolls. It's fine for a small component, but I wouldn't trust it for global typography shifts yet. Still way better than the nightmare of managing a hundred different utility classes just to tweak some tracking. Just keep an eye on those heavy glyphs.



File: 1793741987770.jpg (296.96 KB, 1024x1024, img_1793741979099_wo0ujp6i.jpg)ImgOps Exif Google Yandex

7de12 No.2431[Reply]

saw someone trying to rebuild nth-child using the new if() syntax and it's kind of wild. the whole idea is to use variables like -A and -B so you don't have to hardcode everything into your selectors.
> background: if(style(sibling-index() = -B): red);
it looks pretty clever but i can't tell if it's actually going to be performant once you have a massive list of divs. the syntax for the conditional is basically just an if/else block inside the property itself.
.container {  --A: 5;  --B: 8;}

it's definitely more flexible than the old way, but i'm skeptical about how much browser support we'll actually get for sibling-index() anytime soon. seems like a lot of overkill for just changing a background color. anyone tried running this in a real production build yet?

link: https://css-tricks.com/re-implementing-nth-child-with-modern-css/

8f4e4 No.2438

>>2431
>it's definitely more flexible than the old way, but i'm skeptical about how much browser support we'll actually get for sibling-index() anytime soon.

I don't think performance is even going to be the bottleneck here since it's just a simple index check. The real hurdle is that browsers usually roll out these types of functions with very limited support first, so it'll probably be years before we can use it without huge polyfills or something.

8f4e4 No.2446

File: 1794011055432.jpg (205.41 KB, 1024x1024, img_1794011039468_ecw3in3e.jpg)ImgOps Exif Google Yandex

>>2438
>The real hurdle is that browsers usually roll out these types of functions with very limited support first

Exactly. Even if it works, you'll end up writing a massive fallback block just to prevent the whole layout from breaking for everyone else. I tried something similar with custom properties in a recent dashboard project and the debugging was a total nightmare when the values didn't resolve.
never use style() for mission critical logic



File: 1793784738110.jpg (273.56 KB, 1024x1024, img_1793784729381_g8d5i3m9.jpg)ImgOps Exif Google Yandex

43fb9 No.2432[Reply]

been thinking about this all morning because i just pushed some container queries to replace a resizeobserver setup and it felt so clean at first. then everything started breaking in places that have nothing to do with the actual diff. it's like we're trading away visibility for shorter files.
>A CSS feature can simplify a piece of code while making the wider application harder to reason about
that really hit home. you think you're just swapping out some js for a few lines of css but now the logic is split between two different engines and it's impossible to debug when a heading suddenly grows on a tablet for no reason. it's basically local simplicity vs system complexity. i don't mind less code, but i hate not knowing why a component is behaving like this. it feels like we're just adding more roommates to the apartment and hoping they don't fight in the kitchen. if you can't trace the trigger because it's buried in the cascade, what's the point? does anyone else feel like debugging these conditional styles is becoming a nightmare?

link: https://smashingmagazine.com/2026/11/modern-css-might-make-your-front-end-more-complex/

f8a06 No.2443

File: 1793966921208.jpg (187.08 KB, 1000x1400, img_1793966904604_i883f70f.jpg)ImgOps Exif Google Yandex

>>2432
the roommate metaphor is too real for me. i started using custom properties to force the container state into a visible variable on the :root level, so at least i can see it in the devtools inspector when things go sideways. works fine for simple layouts but gets way too heavy if you're trying to track everything across a whole site.

f8a06 No.2444

File: 1794002901641.jpg (48.4 KB, 1000x750, img_1794002887125_w5wmjlb8.jpg)ImgOps Exif Google Yandex

>>2432 i've started adding a specific data attribute to the container element whenever a container query trigger hits a certain threshold. It doesn't work for complex nested layouts because it adds too much clutter, but it makes the devtools much easier to read when you're hunting down a weird font size change.



File: 1793966759451.jpg (175.5 KB, 1212x872, img_1793966748658_h4m1ccpu.jpg)ImgOps Exif Google Yandex

0c23b No.2442[Reply]

been messing with subgrid on some complex card layouts lately. honestly thought it was gonna be another one of those features that works in chrome but breaks everywhere else. turns out it actually holds up pretty well if you dont overthink the tracks. i was trying to align headers across different containers without using a bunch of hacky margins or fixed heights. it makes everything so much cleaner than the old way of nesting flexbox inside grid and praying for the best. just define the subgrid on the child and let it inherit the parent tracks. no more weird gaps or uneven alignment when content varies between cards. its kinda wild how much simpler my stylesheets look without all that extra padding math. definitely worth checking out if you are still stuck using manual offsets for everything. lmao i almost went back to my old way out of habit.


File: 1793576120451.jpg (232.93 KB, 1024x1024, img_1793576112558_lt55lu5s.jpg)ImgOps Exif Google Yandex

aa97a No.2425[Reply]

using a hook to block commands when things are uncommitted sounds like overkill but i get it after seeing that checkout wipe edits in groupliv.
>the fix was not only another line of instructions. It was a hook that refuses that command while anything is uncommitted.
tbh if i let an agent touch my git workflow without some kind of version check, i'd probably lose everything too. id rather just use a pre-commit hook than deal with a CLAUDE.md that ignores my actual instructions

more here: https://dev.to/yussieik/ai-agents-write-almost-all-my-code-a-review-counts-for-one-exact-commit-4b0m

34462 No.2437

>>2425
>id rather just use a pre-commit hook than deal with a CLAUDE.md that ignores my actual instructions

happened to me last week with a freelance vite project. agent went on a rampage trying to fix some types and ended up overwriting the entire tailwind config without even asking. lost like three hours of custom utility work because i didnt check the diff before it finished. definitely need a hard block. its way too easy for these things to just hallucinate deletions when they get stuck in a loop. hook is the only way to stay sane.

34462 No.2441

>>2437
>agent went on a rampage trying to fix some types and ended up overwriting the entire tailwind config without even asking

same thing happened with a client's landing page last month. i left the agent running on a refactor task and it decided my custom keyframes were "redundant" and just deleted them from the css file. i didn't realize until i tried to run the build later that night. never trust the auto-apply without checking your git status first.
it took me an hour of digging through reflog to find the right state



File: 1793827819311.jpg (109.04 KB, 1024x1024, img_1793827811033_3vor0qfz.jpg)ImgOps Exif Google Yandex

099fe No.2433[Reply]

been cleaning up some messy config files and realized i don't need to bloat my theme with custom spacing just for thin borders. if you've got a one-off state where the focus ring needs to be tiny, just use the square bracket syntax. it saves so much space in the tailwind.config.js when you're dealing with weird design specs.
ring-[0.5px]ring-offset-[1px]

it's way cleaner than adding a custom utility for every single pixel value. anyone else still bloating their config with these one-off values?

099fe No.2436

>>2433
adding custom spacing for every single weird design request is a nightmare. i've started doing this for shadows too because border-width alone doesn't handle the depth needed for those tiny subtle glows. just don't overdo it or your html looks like a mess

099fe No.2440

>>2436
Shadows are definitely where it gets out of hand. I had a client request this specific 'soft glow' effect last week that required three different layers of blur and opacity. I just used the arbitrary value syntax for the box-shadow instead of messing with the theme config. It makes the template much easier to read when you aren't hunting through a 500-line javascript file to find one specific hex code or pixel value. Just be careful with too many of these in one component.

box-shadow: 0 0 2px rgba(0,0,0,0.1),

0 0 4px rgba(0,0,0,0.1)

If you start seeing dozens of these on a single element, maybe it's time to move it back to the config.



File: 1793929834770.jpg (149.28 KB, 1024x878, img_1793929825193_7kjs4zzi.jpg)ImgOps Exif Google Yandex

06649 No.2439[Reply]

been messing around with a nested loop to spit out utility classes for a custom grid system. it works okay for simple stuff but i keep running into issues when i try to target specific column spans without creating a massive, bloated stylesheet. tried using an @each loop with a list of numbers, but the output is just way too much junk for the final build. i was thinking about using a map instead to limit the scope but now the syntax is getting super confusing.
@for $i from 1 through 12 {.col-span-#{$i} {grid-column: span #{$i} / span #{$i};}}

it's making my compiled css file look like a total mess. also just found this cool trick with CSS variables for theme colors while fixing this, so that was a nice little win.


File: 1793907121898.jpg (63.58 KB, 1000x1000, img_1793907114296_vdth8tiy.jpg)ImgOps Exif Google Yandex

666bd No.2435[Reply]

I was just looking at this tidy-typography thing and that text-box-trim stuff is actually insane for fixing vertical rhythm.
>text-box: trim-both cap alphabetic;
It basically kills the half-leading mess, which is nice a total lifesaver if you're tired of fighting with margins. I'm still a bit skeptical about using cqi for fluid type in sidebars though, because it feels like asking for trouble once browser support gets even weirder.
:root {  --step-0: clamp(1rem, 0.9rem + 1cqi, 1.125rem);}


more here: https://css-tricks.com/taming-typography-modern-css-reset/


File: 1793864305097.jpg (223.71 KB, 1080x720, img_1793864294731_pkz6k7ta.jpg)ImgOps Exif Google Yandex

738ab No.2434[Reply]

im tired of seeing people use opacity separately when they could just bake it into a single transform property if they really wanted to. its basically doubling the work for the compositor engine and making things jittery on low end mobiles.
> animating opacity on top of transform
its always never better than just using one well-defined keyframe block.


File: 1793705763080.jpg (121.92 KB, 1024x1024, img_1793705753306_60rv45bj.jpg)ImgOps Exif Google Yandex

f4362 No.2430[Reply]

stop trying to use position: sticky on every single child element. just set your header row to height: 0 or something and use grid-template-rows with a fixed pixel value for the top track. it keeps the scroll math from breaking when you have weird overflow settings on the parent.

grid-template-rows: 60px 1fr;


tbh it's much cleaner than fighting with z-index layers everywhere


Delete Post [ ]
Previous [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
| Catalog
[ Home / About / Contact / WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]