hi i am new to css and i am trying to do a parallax scrolling with the 1920x750 image size. I try with background-attachment: fixed; & transform: translateZ(-300px) scale(2); it will larger my image size. i wanted to use my original banner size to do parallax scrolling
can refer to this Edit fiddle - JSFiddle - Code Playground
<div class="sections">
<section class="section1">
<div class="banner_img">
<img src="https://commonbond.org/wp-content/uploads/2023/10/open-doors-banner-2.jpg"/>
<div class="content">
<h1>This is a testing image</h1>
</div>
</div>
</section>
<section class="section2">
<div class="banner_img">
<img src="https://static.elite-wheels.com/wp-content/uploads/2023/02/2023.2-MTBBanner.webp"/>
<div class="content2">
<h1>This is a testing image</h1>
</div>
</div>
</section>
<section class="section3">
<div class="banner_img">
<img src="https://i0.wp.com/madisonpac.com/wp-content/uploads/2020/03/Page-Title-Banner-Assets-Management.jpg?ssl=1"/>
<div class="content">
<h1>This is a testing image</h1>
</div>
</div>
</section>
<section class="section4">
<div class="banner_img">
<img src="https://www.wickedlywelsh.co.uk/cdn/shop/collections/WW-Easter-banner5.jpg?v=1625184016"/>
<div class="content2">
<h1>This is a testing image</h1>
</div>
</div>
</section>
</div>
*,
html {
margin: 0;
padding: 0;
font-family: "Montserrat";
box-sizing: border-box;
}
.sections
{
height:100vh;
}
.section1,
.section2 ,.section3,.section4 {
perspective: 1;
transform-style: preserve-3d;
overflow-y: scroll;
position:relative;
}
.content{
position: absolute;
top: 80%;
right: 10px;
text-align: center;
color: #00000;
z-index: 1;
font-size:25px;
}
.content2{
position: absolute;
top: 3%;
left: 15px;
text-align: center;
color: #fff;
z-index: 1;
font-size:25px;
padding:8%;
}
.banner_img {
width: 100%;
position: relative;
overflow: hidden;
z-index: -1;
margin:0;
}
img {
width: 100%;
}