JSFiddle - React, Tailwind, and code Playground
HTML
<div class="wrapper">
<img src="" alt="qwe">
</div>
<div class="light">
<img src="" alt="modal">// атрибут src пуст
</div>
CSS
.wrapper img {
height: 100px;
width: 100px;
}
.light{
height: 100px;
width: 100px;
background: red;
visibility: hidden;
}
.light img{
height: 50px;
width: 50px;
opacity: 0;
transition: all 3s;
}
.light.fade img{opacity: 1;}
.light.open{
visibility:visible;
}
JavaScript
$(document).ready(function() {
$('.wrapper img').click(function() {
$('.light').addClass('open');
$('.open img').on('load', function() {$('.light').addClass('fade')}).attr('src', 'http://www.sunhome.ru/i/cards/39/prazdnik-den-zemli-kartinka.orig.jpg');
});
$('.light').click(function() {
$(this).removeClass('open')
});
});