I'm struggling to align multiple images horizontally on the page with a hover effect for each image. I can achieve one or the other separately, but not both together. As a beginner in HTML/CSS, I know it's a simple process.
Below is my code with hover effects but without a horizontal scrollbar:
<!DOCTYPE html>
<html>
<head>
<style>
.container {
position: relative;
width: 50%;
}
.image {
opacity: 1;
display: block;
width: 100%;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
}
.middle {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%)
}
.container:hover .image {
opacity: 0.3;
}
.container:hover .middle {
opacity: 1;
}
</style>
</head>
<body>
<div class="container">
<img src="lb.jpg" alt="" class="image" style="width:100%">
<div class="middle">
<img src="bungalow.jpg" alt."">
</div>
</div>
<div class="container">
<img src="lb2.jpg" alt="" class="image" style="width:100%">
<div class="middle">
<img src="bungalow2.jpg" alt."">
</div>
</div>
<div class="container">
<img src="lb3.jpg" alt="" class="image" style="width:100%">
<div class="middle">
<img src="bungalow3.jpg" alt."">
</div>
</div>
</body>
</html>
And here is my code with a horizontal scrollbar but no hover functionality:
<!DOCTYPE html>
<html>
<head>
<style>
.slide-container {
overflow: auto;
white-space: nowrap;
}
</style>
</head>
<body>
<div class="slide-container">
<img id="slideone" src="lb.jpg" />
<img id="slidetwo" src="lb2.jpg" />
<img id="slidethree" src="lb3.jpg" />
<img id="slidefour" src="lb4.jpg" />
</div>
</body>
</html>
My aim is to merge these two functionalities seamlessly!