Here’s a simple example using HTML and CSS:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hover Image Popup</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<div class="image-popup">
<a href="#">Hover over me</a>
<div class="popup-image">
<img src="/your-image.jpg" alt="Popup Image">
</div>
</div>
</body>
</html>
CSS (`styles.css`)
.image-popup {
position: relative;
display: inline-block;
}
.popup-image {
visibility: hidden;
width: 200px; /* Adjust as needed */
position: absolute;
bottom: 125%; /* Adjust as needed */
left: 50%;
transform: translateX(-50%);
z-index: 1;
}
.popup-image img {
border: 1px solid #ddd; /* Optional: Add a border */
border-radius: 4px; /* Optional: Add rounded corners */
}
.image-popup:hover .popup-image {
visibility: visible;
}
Explanation:
1. HTML: Contains a link and a div for the popup image. The popup-image div is the one that shows the image on hover.
2. CSS:
- .image-popup sets the position of the container to relative, which is necessary for the absolute positioning of the image.
- .popup-image starts off hidden (visibility: hidden) and is positioned absolutely relative to the .image-popup container.
- .image-popup:hover .popup-image makes the popup visible when the mouse hovers over the .image-popup container.
Make sure to replace your-image.jpg with the path to your image file. Adjust the CSS properties to fit your design needs, such as width, positioning, or border styles.