CSS Full-bleed effect stacking issue
I was using this CSS full-bleed approach for having background on contained elements:
https://www.youtube.com/watch?v=81pnuZFarRw
It worked all well until I got one of the children with position: fixed applied to it (pop up menu). I can't restructure HTML by taking out such child outside of parent element. I guess it's because clip-path property is creating a new stacking context. So the child is positioned fixed relative to it's containment parent instead of viewport.
I had to resort back to using pseudo element on parent instead to apply such full-bleed background effect.
Did anyone overcome such edge case in any better way by a chance?
Kevin Powell
YouTube
Full-width background inside a container
Give CSS Challenges a follow: https://twitter.com/ChallengesCss
#css #shorts
--
Come hang out with other dev's in my Discord Community
π¬ https://discord.gg/nTYCvrK
Keep up to date with everything I'm up to
β https://www.kevinpowell.co/newsletter
Come hang out with me live every Monday on Twitch!
πΊ https://www.twitch.tv/kevinpowell...
8 Replies
without an example its hard to say, but you could also do a it as a pseudo element behind the full-bleed-bg. that should prevent clipping other content
--edit. i just read the last 2 lines of your question more carefully, you already done that. sorry
only other option i can think of is repeating the box-shadow a bunch of time with only x-offset (no spread). then you wouldn't need a clip-path
Thank you for your suggestion!
I actually ended up using a more classical approach with pseudo element:
But I liked your approach way more as sticks to this more neat and short declaration according to the video provided π
I use this class as a utility across various projects. So I guess I will stick to its modified version by you π
Here is the updated utility class with documentation in case anyone stumbles upon the same issue:
There are pro's and cons for both.
the classical approach doesn't even need a custom property, it can just inherit the background color. So it all depends
As with everything, at least in web dev, there is no silver bulletπ₯²
btw, maybe for future things, if you do use that approach
is same as (i dont like transform)
I do appreciate your suggestion!
P.S. May I ask about your preference? Were there any side effects you ran into when using transform as opposed to inset?
well, the transform way adds an unnessesary extra step that first places it a 50% and then moves it back. so i try to avoid it where possible. With the current hardware and browsers you wont notice it, but if something prevents speedy calculation, you could see it jump
I see your point