画像モーダル拡大
<a class="mbig" href=""><img src="●●●●.jpg" alt="" style="width:300px;" /></a>
<div class="modal">
<div class="bigimg"><img src="" alt=""></div>
<p class="close-btn"><a href="">✖</a></p>
</div>
CSS
/* モーダル画像の拡大 */
.modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background-color: rgba(0, 0, 0, 0.8);
display: none;
z-index:9999;
}
.bigimg {
position: absolute;
width: 80%;
max-width: 800px;
top: 80px;
left: 0;
right: 0;
margin-right: auto;
margin-left: auto;
}
.close-btn {
color: #fff;
font-size: 40px;
position: absolute;
right: 20px;
top: 0;
}
.close-btn a {
color: #fff;
text-decoration: none;
}
JS
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(function() {
$('a.mbig').click(function() {
var imgSrc = $(this).children().attr('src');
$('.bigimg').children().attr('src', imgSrc);
$('.modal').fadeIn();
$('body,html').css('overflow-y', 'hidden');
return false
});
$('.close-btn').click(function() {
$('.modal').fadeOut();
$('body,html').css('overflow-y', 'visible');
return false
});
});
</script>
この情報へのアクセスはメンバーに限定されています。ログインしてください。メンバー登録は下記リンクをクリックしてください。
