JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<li class="exam_li"><img id="picture" src="https://www.w3schools.com/css/img_fjords.jpg" alt="Slika Testa" width="60" height="60" class="img-resposive exam-img"></li>
<div id="imgmodal">
<div id="caption"><a id="download-link" download><span class="glyphicon glyphicon-download"></span><a id="download-link" download></a></div>
<span id="close">×</span>
<img class="content" id="img">
CSS
.exam-img:hover {
cursor: pointer;
transition: 0.2s;
overflow: hidden;
}
/* exam_img */
#imgmodal {
display: none;
position: fixed;
z-index: 1;
padding-top: 80px;
left: 0;
top: 0;
width: 100%;
height: 100%; /* Full height */
background-color: rgb(0,0,0); /* Fallback color */
overflow: auto;
background-color: rgb(0,0,0); /* Black w/ opacity */
transition: 0.3s;
}
/* Modal Content (image) */
.content {
margin: auto;
display: block;
height: 90%;
}
/* Caption of Modal Image */
#caption {
text-align: center;
color: #ccc;
position: absolute;
top: 15px;
left: 35px;
font-size: 40px;
margin-top: 0;
}
/* Add Animation */
.content, #caption {
-webkit-animation-name: zoom;
-webkit-animation-duration: 0.6s;
animation-name: zoom;
animation-duration: 0.6s;
}
@-webkit-keyframes zoom {
from {-webkit-transform:scale(0)}
to {-webkit-transform:scale(1)}
}
@keyframes zoom {
from {transform:scale(0)}
to {transform:scale(1)}
}
/* The Close Button */
#close {
position: absolute;
top: 15px;
right: 35px;
color: #f1f1f1;
font-size: 40px;
font-weight: 100;
transition: 0.3s;
}
#close:hover,
#close:focus {
color: #989898;
text-decoration: none;
cursor: pointer;
}
#download-link{
font-size: 25px;
color: #f1f1f1;
font-weight: normal;
text-decoration: none;
transition: 0.2s;
padding: 10px;
}
#download-link:hover {
color: #989898;
}
/* 100% Image Width on Smaller Screens */
@media only screen and (max-width: 768px){
.content {
width: 100%;
max-height: 90%;
height: auto;
}
#close {
top: 2px;
font-size: 40px;
}
#imgmodal {
padding-top: 50px;
}
#caption {
top: -1px;
}
}
JavaScript
var modal = document.getElementById('imgmodal');
var img = document.getElementById('picture');
var modalImg = document.getElementById("img");
var download = document.getElementById('download-link');
img.onclick = function(){
modal.style.display = "block";
modalImg.src = this.src;
download.href = this.src;
}
var span = document.getElementById("close");
span.onclick = function() {
modal.style.display = "none";
}