Responsive image hover zoom using HTML & CSS
Source Code
HTML CODE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<div class="container">
<div class="mainImg">
<div class="imgBox">
<img src="./img/1.jpg" alt="" class="imgHoverZoom">
</div>
<div class="imgBox">
<img src="./img/2.jpg" alt="" class="imgHoverZoom">
</div>
<div class="imgBox">
<img src="./img/3.jpg" alt="" class="imgHoverZoom">
</div>
<div class="imgBox">
<img src="./img/4.jpg" alt="" class="imgHoverZoom">
</div>
<div class="imgBox">
<img src="./img/5.jpg" alt="" class="imgHoverZoom">
</div>
<div class="imgBox">
<img src="./img/6.jpg" alt="" class="imgHoverZoom">
</div>
</div>
</div>
</body>
</html>
CSS CODE
body {
padding: 0;
margin: 0;
box-sizing: border-box;
background-color: rgba(0, 0, 0, .7);
}
.container {
display: grid;
justify-content: center;
align-items: center;
height: 100vh;
}
.mainImg {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
box-shadow: 20px 20px 40px rgba(0, 0, 0, .4);
padding: 50px;
border-radius: 20px;
}
.imgBox {
overflow: hidden;
border-radius: 20px;
}
.imgHoverZoom {
width: 300px;
height: 300px;
object-fit: cover;
border-radius: 20px;
transition: all .7s ease;
cursor: pointer;
}
.imgHoverZoom:hover {
transform: scale(1.5);
}
@media screen and (max-width: 992.99px) {
.mainImg {
grid-template-columns: repeat(2, 1fr);
box-shadow: none;
padding: 20px;
}
}
@media screen and (max-width: 768.99px) {
.mainImg {
grid-template-columns: repeat(1, 1fr);
box-shadow: none;
padding: 10px;
}
.imgHoverZoom {
width: 100%;
}
}
Youtube: https://youtu.be/6-KXH_NnjIw
Fb Page: https://web.facebook.com/Code-With-Me-106904145192164
Instagram: https://www.instagram.com/codewithme643/
0 Comments