Skip to content

Commit 801da5b

Browse files
committed
Hover effect black and white to colour
1 parent 6e77c0b commit 801da5b

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

Html/Hover/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>My First Webpage</title>
7+
<link rel="stylesheet" href="style.css"/>
8+
</head>
9+
<body>
10+
11+
<!-- Image box inside the body -->
12+
<div class="image-box"></div>
13+
</body>
14+
</html>

Html/Hover/leaf.jpg

177 KB
Loading

Html/Hover/style.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* Styling the box */
2+
.image-box {
3+
width: 300px; /* Set the width of the box */
4+
height: 300px; /* Set the height of the box */
5+
background-image: url("leaf.jpg"); /* Set the image for the box */
6+
background-size: cover; /* Ensure the image covers the box */
7+
background-position: center; /* Center the image in the box */
8+
border: 2px solid #000; /* Optional: add a border around the box */
9+
margin: 20px auto; /* Center the box horizontally */
10+
filter: grayscale(100%); /* Convert the image to black and white */
11+
transition: filter 0.3s ease; /* Smooth transition for filter changes */
12+
}
13+
/* Hover effect: make the image colorful */
14+
.image-box:hover {
15+
filter: grayscale(0%); /* Remove the grayscale filter to show the image in color */
16+
}

0 commit comments

Comments
 (0)