Hi everybody!
I’m trying to show images in an oyerlay window expanded (means width=100%)
I’m a complete beginner in HTML, JScript or CSS so it’s no miracle that I didn’t came very far.
To show what I mean:
<!DOCTYPE html>
<html>
<head>
<style>
#overlay {
position: fixed;
display: none;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0,0,0,0.5);
z-index: 2;
cursor: pointer;
}
</style>
<script>
function on() {
document.getElementById("overlay").style.display = "block";
}
function off() {
document.getElementById("overlay").style.display = "none";
}
</script>
</head>
<body>
<div id="overlay">
<a href="#" onclick="off()">
<img src="https://images.unsplash.com/photo-1538367999111-0d6c7fb0299f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60'" width="100%" alt="">
</a>
</div>
<table>
<tr>
<td>
<a href="#" onclick="on()"><img src="https://images.unsplash.com/photo-1538367999111-0d6c7fb0299f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60'" width="30%" alt=""></a>
</td>
<td>
<a href="#" onclick="on()"><img src="https://images.unsplash.com/photo-1538367999111-0d6c7fb0299f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60'" width="30%" alt=""></a>
</td>
<td>
<a href="#" onclick="on()"><img src="https://images.unsplash.com/photo-1538367999111-0d6c7fb0299f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60'" width="30%" alt=""></a>
</td>
<td>
<a href="#" onclick="on()"><img src="https://images.unsplash.com/photo-1538367999111-0d6c7fb0299f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60'" width="30%" alt=""></a>
</td>
</tr>
</table><hr>
</body>
</html>
My webpage shows 20+ images in a small size (width=30%). What I want to have is clicking on an image should show the image expanded zu width=100% in an overlay window. Another klick on the expanded picture should remove/close the overlay.
I have absolutely no idea how to make it with ID or class in the IMG-Tag so that the specific image is shown.
Can anybody help me?