When setting the transition-duration: 1s;
for every .pic1,2,3, it can interfere with the parallax effect you desire for the backgroundPosition
. It's important to only specify durations for properties that actually require them, rather than applying it to all properties by default using all
. In this case, you should only use the transition for the filter
property:
Avoid copying and pasting code in CSS!
Instead, create a single rule like this:
/* no need for .pic1, pic2, pic3 { as well */
.pic {
cursor: pointer;
background-size: cover;
width: 30%;
padding: 32px;
display: flex;
flex-direction: column;
justify-content: space-between;
color: white;
transition: filter 1s; /* apply transition only to filter! */
}
.pic1 {
background-image: url(https://www.rgu.hu/CMF/jpg/laser-sci1.jpg);
}
.pic2 {
background-image: url(https://www.rgu.hu/CMF/jpg/life-sci1.jpg);
}
.pic3 {
background-image: url(https://www.rgu.hu/CMF/jpg/data-sci1.jpg);
}
Remember to add the "pic" class to all your HTML elements representing pictures:
class="pic pic1 parallax-image"