File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments