How do I set the one background for all inner-blocks
<div class="outer-block">
<div class="inner-block"></div>
<div class="inner-block"></div>
<div class="inner-block"></div>
</div>
To make it look like in the photo
In the example with the photo, I used the property:
background-attachment: fixed;
.outer-block {
position: relative;
overflow: hidden;
}
.inner-block {
background-image: url('./dsa.jpg');
width: 100%;
height: 200px;
margin: 10px;
background-size: contain;
background-attachment: fixed;
background-repeat: no-repeat;
}
But this implementation has a drawback. When scrolling the page, the image remains fixed relative to the page.
Task: make sure that when scrolling, the internal blocks and the image move synchronously (expected behavior)
2
Answers
Use pseudo element positioned relatively to the container and clipped at child level
Also…