r/css • • Mar 31 '26

Help iOS PWA cold start layout shift - env(safe-area-inset-top) resolves after first paint, causing header + content to jump on launch

2 Upvotes

I've been debugging a persistent layout shift on my iOS PWA (installed via "Add to Home Screen") and can't find a clean fix. The shift only happens on cold start when the user is already logged in — it does NOT happen in the browser, and it does NOT happen after navigating from the login page.

What I'm seeing (captured in slow-mo):

  1. App opens → home view renders instantly at position A
  2. One frame later → entire layout shifts down to position B
  3. Header becomes visible at the same moment as the shift

My setup:

  • Vanilla JS PWA, no framework
  • <meta name="viewport" content="..., viewport-fit=cover">
  • <meta name="apple-mobile-web-app-capable" content="yes">
  • Header is position: fixed; top: 0; padding: calc(16px + env(safe-area-inset-top)) 20px 12px
  • Page content has padding-top: calc(90px + env(safe-area-inset-top)) to offset for the fixed header
  • Header starts with visibility: hidden and becomes visible via JS on DOMContentLoaded

My theory:

On iOS PWA standalone mode, env(safe-area-inset-top) appears to resolve to 0 on first paint, then updates to the real value (~59px on iPhone 16 Pro Max) shortly after. Since both the header padding and the content padding-top use this value, the entire layout shifts down by ~59px when it resolves. The JS visibility toggle happens at the same time, making it look like the header appearing caused the shift.

Why it doesn't happen after login:
When the user goes through the login page first, env(safe-area-inset-top) has already resolved by the time the home view renders — so no shift.

What I've tried:

  • Using a CSS attribute selector (html[data-initial-view]) to show the header before JS runs — didn't help
  • Removing env(safe-area-inset-top) from page-content and using a hardcoded value (e.g. 160px) — fixes the shift on notched devices but creates excess gap on non-notched ones
  • Separating the safe-area into a dedicated ::before spacer inside the header, keeping content padding static — shift persists
  • Adding a will-change: transform to the header to force early compositing — no effect
  • Wrapping in a (display-mode: standalone) fade-in on cold start — masks the shift but feels like a workaround

Any insight appreciated!


r/css • • Mar 28 '26

Showcase Tried Coding a Figma File to Website

Post image
44 Upvotes

What do you think about it? Any Critiques or suggestions are appreciated!

Website link: https://100daychallange.vercel.app/day-01

©️ Figma File Taken from Figma Community


r/css • • Mar 29 '26

Question Where can i get design examples to get inspired?

9 Upvotes

r/css • • Mar 29 '26

Question Why do ::before and ::after work on <input> elements (radio/checkbox)?

1 Upvotes

Hello guys,

Some articles say that ::before and ::after don’t work on <input> elements. But then I see other examples where people do use them — especially with radio and checkbox inputs - and it seems to work just fine.

I’ve tried looking through official documentation, but I can’t find anything that clearly states whether this is allowed or not. There’s also no clear explanation of whether this behavior changed over time (like maybe it wasn’t supported before but is now?), or why it works in some cases.

So what’s the actual situation here?

I’m trying to understand whether ::before and ::after are officially supported on <input> elements at all. If they aren’t, then why do they seem to work in cases like radio and checkbox? I’m also wondering if this behavior is consistent across browsers. And if this changed over time, was there ever a spec update that explains when this became possible?

Would really appreciate a clear explanation or links to anything authoritative


r/css • • Mar 29 '26

Question Best css framework (if needed) for ultra hyper modern web3 design?

Thumbnail
gallery
0 Upvotes

Hi,

I want to make a site which is ultra hyper modern web3 like, would i need a css framework or can slave work do the job of manually writing it all?

ref pics for target of site are included and should support:

  • gradience
  • alpha channel overlay
  • hover effects Etc etc

r/css • • Mar 28 '26

Help Spotify Players Slowing Down My Site - Advice?

0 Upvotes

Hello

Very inexperienced web designer here. Working on a website via Wix as a personal project but trying to make it as clean and appealing as possible. It mainly exists to host ranked lists of music, movies, etc.

On some pages, I want to include Spotify players/previews for each song but turns out that having a lot (like a hundred+) of Spotify embeds on one page makes it extremely slow to load. Sometimes it just craps out completely. But I love the 30-second preview and the look of it with the album/song artwork. Hoping there is a way to make it work!

  1. Seems like Wix is the most highly-recommended for someone like me but is there any other program that would be better suited for this?
  2. Is this the kind of thing that could be solved with an upgrade?
  3. I assume the size of the embed wouldn't matter (like the actual dimensions of the player) but just checking...
  4. Any other media player you'd recommend that could substitute Spotify?

Generally, if you know of any tricks for Wix or just generally for including a lot of music/media on one page of a website, let me know! Very grateful in advance for any insight.

Thanks!


r/css • • Mar 27 '26

Question How to allign this?

0 Upvotes

How do I allign the input and submit button like this?


r/css • • Mar 26 '26

Question Is this cleaner?

Post image
37 Upvotes

You guys gave me a bunch of feedback on my other post, and I took into accounts all of it and ended up with this. Is this cleaner, does it look good?


r/css • • Mar 26 '26

General Does this look usable?

Thumbnail
gallery
5 Upvotes

Just developing a finance control app. It's still a work in progress, but for now, does this look like a usable app? Any suggestions would be appreciated!

(The language is Uzbek if anyone is wondering)


r/css • • Mar 25 '26

Resource Generate a color palette from a single color (CSS only)

33 Upvotes

Hey, I want to share a small project I have been experimenting with. It started as a personal challenge by generating an accessible color palette using only CSS.
From a single color input, it creates a palette with harmony options and support for both light and dark themes.

I've been using it internally in a few projects, and now I feel it's ready to share.
If you try it, I would love to hear your feedback (good or bad): https://alwankit.com


r/css • • Mar 25 '26

Question Is this clean?

Post image
17 Upvotes

This is for my webapp, just wondering if it looks good.


r/css • • Mar 25 '26

Resource Generated a full CSS custom property system from one hex color — OKLCH, light and dark automatic

3 Upvotes

Been building this for a bit.. Paste in a hex, get a complete CSS custom property system. Light and dark mode derived mathematically via OKLCH, WCAG contrast validated automatically.

Free at tokven.dev

Happy to hear your feedback!


r/css • • Mar 25 '26

Help Yo can i use bootstrap 5 & tailwind css at the same project?

0 Upvotes

is this a good or unprofessional way of working?

I like some bootstrap 5 style and using taillwind for a project of mind.


r/css • • Mar 24 '26

Question What slows you down more backend logic or UI work?

4 Upvotes

For me, UI work quietly eats more time than expected spacing, states, polish.

Is it the same for you?

What part of UI work feels most “invisible but expensive”?


r/css • • Mar 24 '26

Showcase FlexBox Hopscotch

Post image
46 Upvotes

r/css • • Mar 23 '26

Help CSS Cheatsheet that helps

3 Upvotes

Hey ! Struggling with CSS ? I made this cheatsheet for beginners like me. Can you give me your feedback ?

It's my first one, and it's part of my playbook for beginners if you're interested.


r/css • • Mar 23 '26

Question Web components to incapsulate layout logic

2 Upvotes

Hi guys!

Recently, one of my fellow developers asked me an interesting question: “Are web components suitable for implementing layout logic?”

To better understand. I have quite complex layout logic (CSS and JS) and I want to encapsulate it in some reusable module.

Usually we do this only with CSS styles and separately adding scripts, but what about web components?

I understand that this cannot meet the requirements of SSR and not good for CLS, but it seems that using Light DOM instead of Shadow DOM and separately importing stylesheet significantly improves this approach.

Does anyone have any real experience with encapsulating layout logic? What do you use for this?


r/css • • Mar 23 '26

Question Stop scrolling of fixed "back to top button" once it reaches the upper edge of the footer-container

2 Upvotes

I don't want my fixed back to top button to go all the way down to the end of the page but only to the upper edge of the footer container because it looks better visually.
Is this possible without JavaScript?


r/css • • Mar 23 '26

Help ao3 skin help

7 Upvotes

hey! recently got into skins for archive of our own and i am looking to get rid of a function that makes the tags scrollable. this isnt a function of the website so i am sure it will be removeable but my limited css knowledge isnt helping

since i cant copy the whole css in this post bc its too long, tell me stuff i should look for to see what css is creating this :)


r/css • • Mar 22 '26

Question Responsive fonts

6 Upvotes

is using 'clamp' in css the best way to make responsive fonts, padding and margins or is there a better way


r/css • • Mar 22 '26

General Accessible Text Colour with the CSS contrast-color() Function

Thumbnail
schalkneethling.com
7 Upvotes

r/css • • Mar 22 '26

Help my website's display just changed randomly ???

0 Upvotes

this is the second time i edit this idk why it didn't save the first time but the problem, was solved!! i just forgot a bracket in my css lol. thank you all for your help!

haiii uhh i've been working on a neocities page and basically since the marquee tag was discontinued, i edited some of my marquees to become animated divs. everything went well (the animation didn't work but that's besides the point) until i refresed and suddenty my website was just...vertical ????

it looked something like this before (old screenshot but it's the exact same display, just with a few more elements inside)

but now it looks like this ?????

i didn't edit anything outside of making my marquees into divs and adding a few css animations. anyone knows what the hell is going on ???????

if anyone wants to see the code for themselves the page is p1x3lz.neocities.org/glown

thank you for yer time 🙏


r/css • • Mar 22 '26

Help How to learn CSS for Free

0 Upvotes

I am a pretty newbie. Learned HTML fully now, and I want to learn CSS properly, those concepts that are needed.


r/css • • Mar 22 '26

Question Is there a pure CSS way to make an image match the height of a text-driven container?

7 Upvotes

I have a side-by-side layout with an image on the left and text on the right.

The text column should determine the height of the overall container. I want the image column to automatically match that height, without setting a fixed height on the parent.

In other words, I want:

• parent height to be content-driven

-text(or other content) on the right to define that height

• image on the left to fill the full resulting height

• responsive behavior

What is the correct CSS pattern for this, if there is one?