「Modal」のことですね。
「Modal」で検索すればいろんな例がでてくるかと思います。
一例として、以下をあげておきます。
html
1<div class="imgs">
2 <img class="modal" src="https://placeimg.com/200/200/nature">
3 <img class="modal" src="https://placeimg.com/200/200/people">
4 <img class="modal" src="https://placeimg.com/200/200/animals">
5 <img class="modal" src="https://placeimg.com/200/200/arch">
6</div>
7<div id="expandModal">
8</div>
css
1.expand{
2 background: #fff;
3 box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
4 display: inline-block;
5 padding: 1em;
6}
7
8#expandModal{
9 display:none;
10 position:fixed;
11 padding-top: 50px;
12 top:0;
13 left:0;
14 z-index:1;
15 width: 100%;
16 height: 100%;
17 overflow: auto;
18 background-color: rgba(0,0,0,0.9);
19}
20
21#expandModal img{
22 margin: auto;
23 display: block;
24 width: 50%;
25 max-width: 700px;
26}
27
JavaScript
1$('.modal').each(function(){
2 $(this).on('click',function(){
3 let src = $(this).attr('src');
4 let modalImage = `<img src=${src} >`;
5 $('#expandModal').append(modalImage);
6 $('#expandModal').show();
7 });
8});
9$('#expandModal').on('click',function(){
10 $(this).hide();
11 $('#expandModal img').remove();
12});
実際の動作: https://codepen.io/unotalk/pen/jdwqzx