https://i.sstatic.net/nIsC7.pngHey there, I'm new to CSS! For a homework assignment in my class, I need to create a box with 4 images. When I hover over an image, it should enlarge and display in the center of the box.
Each image has two files - a small one starting with "th" and a big one starting with "big". This task requires me to work on the attribute selector.
I tried implementing something for this task, but for some reason, it's not working as expected.
body>div {
width: 100%;
height: 800px;
border: 2px solid black;
}
div {
position: relative;
}
div>div {
position: absolute;
top: 200px;
left: 400px;
}
img {
display: block;
margin: 20px 10px;
}
img[src*="th"] {
width: 250px;
border: 3px solid black;
box-shadow: 10px 10px 10px #666;
}
img[src*="/big"] {
display:none;
}
img[src*="th"]:hover {
box-shadow: inset 10px 10px 10px #666;
}
img[src*="th"]:hover+img[src*="/big"] {
display:block;
}
<div>
<img src="/HTML/HW/HW27_5/thCar.jpg" alt="">
<img src="/HTML/HW/HW27_5/thHome.jpg" alt="">
<img src="/HTML/HW/HW27_5/thTree.jpg" alt="">
<img src="/HTML/HW/HW27_5/thPlane.jpg" alt="">
<div>
<img src="/HTML/HW/HW27_5/bigCar.jpg" alt="">
</div>
<div>
<img src="/HTML/HW/HW27_5/bigHome.jpg" alt="">
</div>
<div>
<img src="/HTML/HW/HW27_5/bigTree.jpg" alt="">
</div>
<div>
<img src="/HTML/HW/HW27_5/bigPlane.jpg" alt="">
</div>