Created
February 15, 2019 09:00
-
-
Save ato-s/fcdc8a28d9ebc85922787686cab2888e to your computer and use it in GitHub Desktop.
MODAL --fix modal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="" class="p-top_lineup_list_btn c-btn01 js-modal-btn">購入する</a> | |
<div class="c-modalArea js-modal-box"> | |
<ul class="c-shopNavi"> | |
<li><a href="" target="_blank"><img src="/brand/muko/img/shopbtn02.png" alt="ケンコーコムで購入はこちら"></a></li> | |
<li><a href="" target="_blank"><img src="/brand/muko/img/shopbtn03.png" alt="爽快ドラッグで購入はこちら"></a></li> | |
<li><a href="" target="_blank"><img src="/brand/muko/img/shopbtn04.png" alt="楽天で購入はこちら"></a></li> | |
</ul> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//モーダル | |
var modalBtn = $('.js-modal-btn'); | |
var modalBox = $('.js-modal-box'); | |
var overLay = $('#overlay'); | |
modalBtn.on('click', function() { | |
$('body').append($('<div id="overlay"></div>').fadeIn('fast')); | |
$(this).next(modalBox).addClass('is-show').fadeIn('slow'); | |
if(modalBox.hasClass('is-show')){ | |
$(document).on('click touchend', function(e) { | |
if (!$(e.target).closest(modalBox).length) { | |
modalBox.removeClass('is-show').fadeOut(); | |
$("#overlay").fadeOut().remove(); | |
} | |
}); | |
} | |
return false | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.c-modalArea{ | |
display: none; | |
position: fixed; | |
left: 0; | |
right: 0; | |
top: 50%; | |
width: 800px; | |
margin: auto; | |
z-index: 5; | |
transform: translateY(-50%); | |
} | |
#overlay{ | |
transition: .4s; | |
position: fixed; | |
left: 0; | |
right: 0; | |
top: 0; | |
bottom: 0; | |
z-index: 4; | |
background: rgba(#000,0.4); | |
cursor: pointer; | |
} | |
.c-shopNavi { | |
display: flex; | |
flex-wrap: wrap; | |
border: 1px solid #3eb8ec; | |
padding: 35px 66px; | |
border-radius: 10px; | |
background-color: #fff; | |
a { | |
display: block; | |
border: 1px solid #f0f0f0; | |
&:hover{ | |
opacity: .7; | |
} | |
} | |
li{ | |
&:nth-child(n+4) { | |
margin-top: 16px; | |
} | |
&:not(:nth-child(3n-2)){ | |
margin-left: 14px; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment