Hi everyone!
I’m trying to have the child divs have the same gradient background as the parent div. In other words, I want them to be covered with the same gradient as if they were one unit. Is it possible?
I tried background-position: fixed, the child elements are covered just fine BUT the background gradient changes as I scroll the viewport upward/downward!
Edit: so that’s happening because background-position: fixed is relative to the viewport. Is there any way to make relative to the parent element?
I’m really having a hard time trying to formulate my question - sorry!
My problem is pretty straightforward: I want to make the child divs inherit the same gradient background from the parent (as if they were part of the parent div themselves, not just child divs).
The only way I found was to background-attachment: fixed. But it’s not a solution since this property is relative to the window/viewport, not to the parent div. That’s why the gradient is changing when you scroll up/down.
I would need to either see an image, a page example like maybe you have seen this effect someplace you can reference, or some code of the actual layout you are going for (including the scroll). Right now I just don’t understand what you are asking for, sorry.
Are the children going to be outside the parent like they are in the Codepen?
Do you want them to just inherit the color, or act like they are transparent and on top of the parent but actually be outside the parent? So they take the gradient color based on their vertical position.
You say you are trying to draw clouds, can you at least show me what you have so far?
Show me a picture of what you want, and show me some code of what you have so far. Because this box and the circles are really not helping me see the desired effect you are going for.
The code I posted above and the one I have on CodePen are all I have for now. It doesn’t really matter what I am trying to draw, as the point stays the same, ie. How to make children divs with position: absolute inherit the same gradient from their parent div, the div they are nested in?
Could we have the same gradient background in both a parent div and children divs?
The children divs are nest inside a parent container, even if they are positioned outside of it.
As I showed in the gif and in CodePen, the gradient in the children background is changing as I scroll up and down. The point is to make it fixed, I don’t want it to change with scrolling.