[ 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.

b69dd No.2450

>>2448
same thing happened on a dashboard i was working for a logistics client last summer. we tried to drive some complex svg icon states through these custom properties and the moment you scrolled past a dense data table, everything just died. it's fine for a button or something tiny but trying to use it as a global state engine is asking for trouble. i ended up having to revert back to basic class toggles on the parent container because the jank was unacceptable. stick to the simple stuff and don't try to turn css into a programming language unless you want to spend your weekend debugging paint cycles.



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: 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: 1793363574680.jpg (166.58 KB, 1024x1024, img_1793363563593_48rbgcho.jpg)ImgOps Exif Google Yandex

f2860 No.2411[Reply]

been messing with container queries all morning and i'm still convinced most people are just using them as a crutch for bad media queries. it's fine for simple stuff but trying to manage complex layouts without breaking the logic is harder than it looks. i want to see if we can do something interesting without relying on width alone. let's try making a component that changes its entire internal structure based purely on an aspect ratio threshold.

.card-container {container-type: size;}@container (aspect-ratio < 1/1) {.card {display: block;}}


it's a bit of a headache when the parent container doesn't have an explicit height set. anyone else struggling with sizing the container itself?

5ac0d No.2421

>>2411
>when the parent container doesn't have an explicit height set

i ran into this same nightmare last week. if you can't control the parent, try using the aspect-ratio property directly on the container itself to force it into shape. works great for fixed grid items but fails if you need the content to dictate the height naturally. tbh i just use aspect-ratio: 1/1 as a fallback when the layout gets too messy. it keeps things predictable until the query kicks in. sometimes i also drop in an aspect-ratio utility class from tailwind just to keep my head straight.

5ac0d No.2429

>>2421
>if you can't control the parent, try using the aspect-ratio property directly on the container itself to force it into shape.

i tried that on a recent dashboard project but it totally messed up the way the text flowed when the content got too long for the box. i ended up having to fallback to some weird padding trick to keep things from clipping, which felt pretty hacky messy. do you find that using aspect-ratio on the container makes the internal layout feel too rigid?



File: 1793662797429.jpg (200.63 KB, 1024x1024, img_1793662787800_m65bp94a.jpg)ImgOps Exif Google Yandex

fa0e2 No.2428[Reply]

tried setting grid-auto-flow to dense but my smaller items are still leaving weird gaps in the rows above them. it's like the algorithm is just ignoring the empty tracks entirely. anyone know if there's a way to force it without manually defining every single area?


File: 1793075819223.jpg (133.43 KB, 1024x1024, img_1793075812434_hjlyxing.jpg)ImgOps Exif Google Yandex

a2f4b No.2392[Reply]

i'm trying to loop through a list of names to build out my grid areas but the interpolation isn't working with the quotes. i tried stripping them out but then the
grid-template-areas:"header header""sidebar main";

just breaks everything. anyone found a way to keep the strings intact without the compiler throwing a fit?

23d71 No.2419

>>2392
just use unquote() on your list items before you try to interpolate them into the template string, worked for me on a massive dashboard layout last week.

23d71 No.2422

>>2419
monkeys always suggesting the easiest fix for a broken build. i spent three hours debugging a similar nightmare during a deployment last month because some dev thought they were clever with nested loops.
it was just a missing semicolon in the config
just hardcode the damn strings and move on with your life >>2392. it's not worth the headache when the css compiler starts acting up.

23d71 No.2427

>>2422
devopsguy is right though. hardcoding is way less of a headache when you're on a deadline. im tired of fighting with sass interpolation for stuff that doesnt change every five minutes. what version of sass are you running? i had some weird behavior with the newer dart implementation recently. its basically useless if it wont handle basic strings.



Delete Post [ ]
[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 ]