[ 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: 1795925919575.jpg (107.49 KB, 1024x682, img_1795925910854_yj20yzl1.jpg)ImgOps Exif Google Yandex

18aa1 No.2557[Reply]

I've been using this to fix lag on pages with massive DOM trees. It basically tells the browser not to bother rendering anything outside the viewport. You don't need a complex intersection observer setup if you just want a quick win for scroll performance. Just make sure you set a minimum height so the scrollbar doesn't jump around when things load in.

.list-item {content-visibility: auto;contain-intrinsic-size: 0 50px;}


The intrinsic size part is important because it keeps the layout stable. It works best with content-visibility on repeating components like cards or list rows.


File: 1795889315484.jpg (116.82 KB, 1024x683, img_1795889306945_pchv4zcp.jpg)ImgOps Exif Google Yandex

79e9f No.2554[Reply]

I'm tired of writing dozens of media queries just to scale my margins and padding. It gets messy fast when you have a complex layout. I started using a simple sass function that wraps everything in a clamp call so the values fluidly adjust between a min and max size based on viewport width. You don't need massive breakpoint files if your spacing just breathes with the screen. Just pass your minimum value, your preferred value (usually something tied to vw), and your maximum limit. It keeps the stylesheet much cleaner than manual overrides.

@function fluid-space($min-size, $max-size, $min-breakpoint: 320, $max-breakpoint: 1280) {$min-vw: ($min-size / $min-breakpoint) * 100;$max-vw: ($max-size / $max-breakpoint) * 100;$slope: ($max-vw - $min-vw) / ($max-breakpoint - $min-breakpoint);$y-axis-intersection: -$min-vw + $slope * $min-breakpoint;@return clamp(#{$min-size}px, #{$y-axis-intersection}px + #{$slope * 100}vw, #{$max-size}px);}.card {padding: fluid-space(16, 48);}


The math is a bit heavy for a one-off, but it's worth it for design systems. It prevents that weird jumpy feeling when a user resizes their browser. Just make sure your base font size stays consistent or the math breaks.


File: 1795558461521.jpg (157.58 KB, 682x1024, img_1795558453290_hakfr2mi.jpg)ImgOps Exif Google Yandex

e8347 No.2531[Reply]

been using standard cubic-bezier everywhere but its so stiff. if u want that bouncy feel for buttons or cards without writing massive keyframe sets just use spring values in your ease function. i stopped using linear bezier curves for everything last week. it makes the UI feel way more alive when things snap into place.

transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);


the last value is what gives it that overshoot effect. works great for small scale transforms or subtle shadows on hover. simple as hell.

e8347 No.2532

>>2531
>the last value is what gives you that overshoot effect
don't use that for anything bigger than a button or it'll look like your site has a seizure because the layout jitter is unbearable.

e8347 No.2546

File: 1795739557874.jpg (164.07 KB, 1024x1024, img_1795739544215_w7j80kn9.jpg)ImgOps Exif Google Yandex

>>2532
devopsguy is wrong about the jitter. if u keep the overshoot values tiny it just feels premium instead of broken. it's basically just physics

e8347 No.2552

>>2546
calling that premium is a stretch when you're just masking bad timing. if you actually want weight, you need to adjust the duration too because a fixed 0.5s with an overshoot always feels like it's floating instead of snapping.



File: 1795846105622.jpg (133.41 KB, 1100x755, img_1795846097466_51j8md3b.jpg)ImgOps Exif Google Yandex

c5234 No.2551[Reply]

I finally ditched the old padding top trick for actual aspect ratio on my last project. It makes the code so much cleaner when I am trying to scale video containers or images without doing that weird math every single time.


File: 1795478962760.jpg (190.72 KB, 1200x860, img_1795478924278_620x8ezp.jpg)ImgOps Exif Google Yandex

edac9 No.2529[Reply]

i've been seeing so many design systems still relying on sass color functions for everything like lightness or saturation and it honestly feels like we're fighting ignoring how much better native css color-mix is getting. when you use sass to pre-calculate these values, the colors are baked into the static css file so you lose that ability to let the user change a theme or tweak a brightness slider in real time via javascript. it makes the dev experience feel so much more rigid when we could just be passing variables around and letting the browser handle the heavy lifting of blending. i really think we should be moving toward using native functions for anything that isn't a hardcoded brand color to keep things flexible.
--brand-primary: #3498db;--brand-light: color-mix(in srgb, var(--brand-primary), white 20%);

does anyone actually find the sass math more predictable for complex component states?

edac9 No.2545

>>2529
>the colors are baked into the static css file so you lose that ability to let the user change a theme

I've been using oklch() for this exact reason lately because it's way easier to tweak lightness without messing up the hue. It works great for those dynamic sliders, but I still stick to sass for my heavy brand palettes where I need pixel-perfect consistency across old browsers that don't handle color-mix well yet.

edac9 No.2549

File: 1795768065812.jpg (119.68 KB, 1000x960, img_1795768050761_tmtw41zc.jpg)ImgOps Exif Google Yandex

>>2529
>>2545 oklch is fine but you still cant rely on sass for pixel-perfect consistency if your users are on browsers that dont support it anyway.



File: 1795760407936.jpg (118.7 KB, 1024x920, img_1795760398325_x5k2qdgd.jpg)ImgOps Exif Google Yandex

a2673 No.2548[Reply]

spent all morning fighting a layout because i used auto-fill instead of auto-fit on a product grid. it looks totally broken when there's only two items in the row since they just hug the left side instead of stretching to fill the space. i keep forgetting that auto-fill basically creates empty tracks even if nothing's in them, which is smart annoying as hell for responsive cards.

grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));


does anyone actually prefer auto-fill for anything specific?


File: 1795356769189.jpg (66.43 KB, 1024x682, img_1795356760937_9pp8alis.jpg)ImgOps Exif Google Yandex

a8cb0 No.2522[Reply]

been looking at some legacy tailwind configs where they're still using arbitrary values for every single image instead of just setting a base class with aspect-ratio: 16/9. it's basically just a massive bloated config file full of stuff that should be native css now

a8cb0 No.2539

File: 1795661446875.jpg (129.2 KB, 682x1184, img_1795661431011_92cy647u.jpg)ImgOps Exif Google Yandex

>>2522
arbitrary values are better for one-off edge cases where you don't want to pollute your global stylesheet with a dozen specific ratios you'll never use again.

a8cb0 No.2543

>>2539
>arbitrary values are better for one-off edge cases where you don't want to pollute your global stylesheet with a dozen specific ratios you'll never use again

makes sense for weird stuff but most of these devs just get lazy. i see people using
aspect-[4/3]
and
aspect-[5/4]
on every single card component like it's some kind of flex. if you're doing that you might as well just drop a single class with the actual property in your css file. utility hell is real when you start seeing twenty different arbitrary values for basically the same layout. tbh it's just unnecessary bloat in the bundle once you scale up



File: 1795277308655.jpg (319.18 KB, 1000x1000, img_1795277302110_nm926x5u.jpg)ImgOps Exif Google Yandex

eae6f No.2519[Reply]

I've been cleaning up some legacy code where everything uses the old
map-get
function. It's basically fine, but switching to the modern Sass modules syntax makes it harder to accidentally use global functions that might get deprecated. Use @use 'variables' as v;\n@get: v.$colors. primary; instead of the old way once you've moved your files over. It keeps things much cleaner when your project grows.

eae6f No.2540

>>2519
i ran into this exact headache during a massive redesign for a client last month because their old codebase was such a mess of global functions that it felt impossible to trace where variables were actually coming from. once we started moving everything over to the module system, i finally felt like i could actually trust our build process without worrying about some random color variable breaking something elsewhere. do you find that migrating those legacy maps usually takes as long as you expect?

eae6f No.2542

>>2519 I spent a whole weekend hunting down a rogue hex code in a massive brand guide because some intern used a global function that was shadowing our actual theme map. Switching to the module system saved my sanity since at least I can see exactly which namespace is being pulled in when things start looking wonky.



File: 1795680955173.jpg (112.15 KB, 1300x906, img_1795680917408_wdopwm80.jpg)ImgOps Exif Google Yandex

4e50a No.2541[Reply]

I'm honestly sick of seeing people use margin instead of the gap property for spacing out flex items. It makes the hierarchy such a mess when you have to account for that extra edge case on the last child.
>margin-right: 1rem;
It's just clunky as hell compared to a clean gap implementation.


File: 1795112169330.jpg (173.59 KB, 1024x1024, img_1795112160345_q2n6glt5.jpg)ImgOps Exif Google Yandex

25810 No.2502[Reply]

saw mat's post about those sidenote components he's building for his site. it's basically just an aside wrapped in some markdown through an eleventy shortcode, but the way he's styling them is a bit much. he's using animation-timeline: view() to make them scale up as they hit the center of the viewport. then he adds a little transform: rotate(2deg) because apparently perfectly straight text is too boring for him.
>a perfectly squared span of text wasn't quite getting that across
it feels like overkill for some marginalia, but i guess it works if you want that hand-scribbled look. the grid layout part seems straightforward enough, though i'm not sure how much performance hit you get with all those scroll-driven animations happening at once. honestly, it's just a lot of work to make something look slightly messy on purpose. i'd probably just stick to a simple rotation and call it a day. does anyone actually use view() for minor UI polish like this in production?

article: https://piccalil.li/blog/understanding-css-random/?ref=main-rss-feed

25810 No.2517

File: 1795263927515.jpg (176.19 KB, 1024x1024, img_1795263912391_swfz327b.jpg)ImgOps Exif Google Yandex

>>2502
>i'm not sure how much performance hit you get with all those scroll-driven animations happening at once.

If he's just scaling and rotating, it shouldn't tank anything since they're compositor-only properties. You only really need to worry about a laggy main thread if he starts adding heavy box-shadows or filters to the animation loop. Use
will-change: transform
on the aside elements if there are dozens of them on one page, but it's probably overkill for a standard blog post.

25810 No.2526

File: 1795415699691.jpg (243.12 KB, 1000x1000, img_1795415684719_p0fgt3qn.jpg)ImgOps Exif Google Yandex

>>2517
I think you're right about it being compositor-only, but I still worry about mobile browsers getting weird with too many active timelines. >>2502 did you actually try testing that view() animation on a mid-range phone or are you just assuming it'll be fine? It felt janky when I tried something similar for a client project last month.

25810 No.2538

>>2526
>It felt janky when I tried something similar for a client project last month.

I ran into that too with Safari on iOS. The scroll-driven animations seem fine on desktop Chrome, but the moment you hit mobile, the frame rate drops like crazy if the elements overlap. It's probably because of how the browser handles the intersection calculations while trying to render the rest of the page. I've started using a simple intersection observer as a fallback to just toggle a class instead of relying on the timeline. It doesn't give you that smooth scaling effect, but it keeps the scrolling from feeling like sludge. If you really want the animation, maybe limit it to only the first few notes or something.



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 ]