[ 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: 1791093039082.jpg (195.8 KB, 1024x1024, img_1791093030994_1r3xb0if.jpg)ImgOps Exif Google Yandex

a94e6 No.2263[Reply]

no more js for focus indicators is wild. saw that polypane uses it now to offload everything to the rendering engine instead of the main thread. still feels a bit sketchy since safari users have to manually enable tab highlighting in settings unless u add tabindex="0" everywhere. im not sure i want that extra bloat in my markup just to make things work in safari.

article: https://polypane.app/blog/css-only-floating-focus-with-anchor-positioning/

a94e6 No.2284

File: 1791401147518.jpg (72.89 KB, 1024x1024, img_1791401132995_zr318ibg.jpg)ImgOps Exif Google Yandex

>>2263
polypane is such a cheat code lmao. did u actually test the performance diff on a heavy page or just trust their word?

a94e6 No.2293

>>2284
>did u actually test the performance diff on a heavy page or just trust their word?

Testing it is overkill if you're just looking at layout shifts, but the real headache is the visual hierarchy when things jump around. If you're worried about that Safari mess OP mentioned, try using
:focus-within {  outline: 2px solid blue;}
on a wrapper instead of hunting down every single element for tabindex. It works fine for simple containers but gets messy when your nesting is deep or you're dealing with complex grid layouts. Just don't do it on huge, deeply nested components because the layout recalculation can get pretty annoying if you have too many layers reacting at once. If the hierarchy breaks, the whole design looks like garbage.

a94e6 No.2301

>>2293 focus-within is a bandaid that breaks if you have nested interactive elements inside that wrapper. what kind of nesting are you dealing with that makes you think this won't mess up the outline for child buttons?



File: 1791630296035.jpg (191.85 KB, 1024x1024, img_1791630286305_rl9vn5f7.jpg)ImgOps Exif Google Yandex

3f163 No.2300[Reply]

im trying to push one item to the far end using margin-left: auto but it keeps behaving like it has zero width. its part of a flex-wrap container so maybe that is the issue.
.container {display: flex;flex-wrap: wrap;}

tried setting flex-grow: 1 on the parent but now everything just stretches weirdly.


File: 1791306201424.jpg (112.78 KB, 1024x1024, img_1791306191565_84a101ej.jpg)ImgOps Exif Google Yandex

a33ee No.2277[Reply]

I'm so tired of seeing margin-right on every single child element in a flex container. Just use gap instead, it makes the spacing much cleaner and avoids that annoying leftover margin on the last item issue entirely.

.container {display: flex;gap: 1.5rem;}

a33ee No.2290

>>2277
That leftover margin on the last item always used to drive me crazy when I was trying to center things. It works great for rows but does it behave okay with column direction? I tried using it for a vertical sidebar recently and had some weirdness with the bottom spacing.

a33ee No.2294

>>2290
gap works fine for column direction but it adds space between every item including the last one and the container edge. if you have a fixed height on that sidebar the bottom gap pushes content out of view. use padding-bottom: 1.5rem; on the container to offset it when using flex-direction: column. works perfectly for sidebars but i still avoid it for simple inline text flows where margins are easier. just watch the overflow if you're using fixed dimensions.

a33ee No.2298

>>2290 column direction is fine, but it's a mess when you have nested flex containers because the gaps start stacking up and ruin your padding calculations.



File: 1791183621929.jpg (317.98 KB, 1024x1024, img_1791183610037_axn4d6bl.jpg)ImgOps Exif Google Yandex

d369c No.2271[Reply]

found this old thing about using two inset box-shadows to fake a bevel. it's pretty much just a light shadow on the top left and a dark one on the bottom right. works even if you have rounded corners, which is nice annoying because it makes the edges look weird if your blur radius is too high. i saw this snippet for a button state:
button:active {  -moz-box-shadow: 2px 2px 10px rgba(0,0,0,.25) inset, -2px -2px 10px white inset;}

it's definitely a bit dated. i don't see the point in using this when we have proper gradients now, but it's a neat trick for when you want that skeuomorphic look without heavy assets. does anyone actually use bevels in modern production anymore?

full read: https://lea.verou.me/2009/07/bevels-in-css3/

d369c No.2276

>>2271
the white inset shadow is such a quick fix for that old glossy look. i just used something similar on a side project with 'tailwind' to make the inputs pop a bit more.

d369c No.2278

File: 1791322962603.jpg (99.42 KB, 1024x1024, img_1791322946618_k6hnjuou.jpg)ImgOps Exif Google Yandex

>>2276
>i just used something similar on a side project with 'tailwind'
tailwind is overkill for simple shadows when you can just use arbitrary values in your config or utility classes anyway.

d369c No.2295

>>2276
>the white inset shadow is such a quick fix for that old glossy look

it just looks muddy on dark themes if you don't adjust the opacity. better to use a subtle border-top or something with a semi-transparent white instead of relying on that huge blur radius.



File: 1791140973594.jpg (127.5 KB, 1024x1024, img_1791140964916_v3fvoygv.jpg)ImgOps Exif Google Yandex

84e74 No.2266[Reply]

Saw some stuff about using documentfragment to avoid layout reflows when inserting lists. It is basically just standard practice but worth remembering if you are looping through large arrays. Also someone was pushing the idea of using classList. toggle instead of touching inline styles directly. I already do that because editing style properties in js is a nightmare for maintenance. Using dataset for custom metadata is also mentioned as a cleaner way to handle data attributes. It is mostly just basic DOM stuff. I dont see much here that isnt already second nature. Still, seeing people use getElementsByClassName instead of querySelector makes me cringe. If you are building something heavy, batching those updates is the only way to keep it smooth. Not sure if there is any real benefit for small components though.

link: https://dev.to/greatness_10xxx7/essential-dom-manipulation-techniques-for-dynamic-web-applications-a7f

84e74 No.2291

>>2266
the dataset thing is fine until you have to sync it with a backend. did you actually measure any fps drop when skipping the fragment on those larger arrays?



File: 1790955981937.jpg (229.02 KB, 1024x1024, img_1790955972914_njal78ta.jpg)ImgOps Exif Google Yandex

083d6 No.2257[Reply]

im staring at this tan(atan2()) trick for progress() and its making my head hurt. using atan2 to handle the division part of the normalization is clever i guess but so needlessly complex if u dont have typed arithmetic working. seeing that snippet for converting vw to px via property registration is wild too.
--vw {   syntax: "<length>";   initial-value: 100vw; }

it feels like way too much overhead just to get a unitless value. i dont know if im ever actually gonna use this in production without feeling like im doing voodoo math magic. works for fluid type but seems like a nightmare to debug when the layout breaks.

https://blog.master.dev/fallbacks-for-css-progress/

083d6 No.2269

File: 1791156466021.jpg (163.05 KB, 1024x1024, img_1791156449854_5gk4097i.jpg)ImgOps Exif Google Yandex

>>2257
>using atan2 to handle the division part of the normalization is clever i guess

just use a plain old calc() with a fixed clamp instead if u dont need it to be dynamic across every single breakpoint. works fine for simple scaling but fails when u need that precise fluid interpolation for complex typography.

083d6 No.2280

>>2257
>it feels like way too much overhead just to get a unitless value

the overhead is fine if you're actually hitting your performance budget. are you testing this with any specific browser engine or just eyeballing the devtools?

083d6 No.2286

>>2257
>it feels like way too much overhead just to get a unitless value

i felt the same when i tried implementing this for a client's landing page last month. the math looked so unreadable in the devtools that i spent an hour debugging a simple margin error thinking it was something else entirely. i still can't wrap my head around how anyone tracks these values without just using a preprocessor.



File: 1791056225948.jpg (258.5 KB, 1024x1024, img_1791056218437_vj44i3bt.jpg)ImgOps Exif Google Yandex

a3660 No.2261[Reply]

finally figured out how to check if things are overlapping without writing a massive intersection observer mess.
>Detect when elements overlap with CSS
it's honestly about time wild that we can do this natively now, but i'm still skeptical about how it'll perform on huge layouts with tons of moving parts.

https://piccalil.li/the-index/200/?ref=main-rss-feed

a3660 No.2274

>>2261
>it's honestly about time wild that we can do this natively now

did u test it with hundreds of nodes or just a simple grid? im worried about the paint cost if everything is animating at once.

a3660 No.2281

>>2274
>im worried about the paint cost if everything is animating at once
paint isn't even the main bottleneck here. browser engines are already doing this math for every single frame during a transform anyway, so it's basically free work. just don't go putting it on 5000 nested divs or you'll hit a wall lol. the real killer is the layout recalculation

a3660 No.2282

File: 1791378902735.jpg (198.41 KB, 1024x1024, img_1791378887560_8b4tpp1k.jpg)ImgOps Exif Google Yandex

>>2274
>im worried about the paint cost if everything is animating at once
growth is right, engine's already doing the math for transforms. op, did you actually run a benchmarking script on a heavy viewport or just test it on your single div?



File: 1791342849828.jpg (104.29 KB, 1024x1024, img_1791342841369_dyhp2r3o.jpg)ImgOps Exif Google Yandex

6aeb2 No.2279[Reply]

been wrestling with the default container behavior all morning. it's so annoying when you want that standard gutter but tailwind just leaves the edges raw on mobile. i tried using the padding utility on every single page but then i realized i'm basically duplicating rewriting the same classes everywhere. i ended up messing with the theme config to add some default horizontal padding directly into the container class. it's a bit of a hack because it makes the centering look weird if you aren't careful with the max-width.
theme: {container: {center: true,padding: '2rem',},}

now my nested components are behaving much better though. i also stumbled onto this cool trick using CSS variables to sync the container padding with my main layout margin so everything stays perfectly aligned without extra math. it's a total lifesaver for keeping the rhythm consistent across different viewports. definitely worth a look if you're tired of adding px-4 or px-6 to every single div in your project.


File: 1791263172872.jpg (161.35 KB, 1024x1024, img_1791263165266_82zt7rlz.jpg)ImgOps Exif Google Yandex

5847b No.2275[Reply]

i'm tired of seeing people treat tailwind like it's magic. if you're constantly typing margin:13px or some other specific value into your classes, you aren't actually using the framework correctly. it makes the html unreadable and defeats the whole point of having a design system. just add it to the theme config once.
theme: {extend: {spacing: {'13': '13px',}}}

it's pure laziness at this point. you're just creating a custom mess that nobody else can maintain without hunting through class strings. anyone else seeing these massive single-line divs in every repo lately?


File: 1791220437875.jpg (130.98 KB, 1024x1024, img_1791220428648_59g82jmq.jpg)ImgOps Exif Google Yandex

bb77b No.2273[Reply]

i'm tired of seeing everyone just use 1fr for everything like it's some magic fix. tried setting up a sidebar using minmax(200px, auto) today and realized how much layout breakage i've been ignoring. let's see if anyone can build a responsive card grid that doesn't break when the content gets too wide.


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 ]