WEB and GRAPHIC
CREATIBE STUDIO
© COPYRIGHT MGM DESIGN TIPS ALL RIGHTS RESERVED.
最終更新:2021/07/30
page.jsの「js-modal-open」などの部分が必要です。
下の「詳しく見る」をクリックすると表示されます。
html
1 2 3 4 5 6 7 8 9 10 11 12 |
<div class="bt_st"><a class="js-modal-open" href="" data-target="modal01">詳しく見る</a></div> <div id="modal01" class="st_modal js-modal"> <div class="modal__bg js-modal-close"></div> <div class="modal__content"> <a class="js-modal-close" href="">×</a> <div class="row"> <div class="col-sm-12"> テキストや画像などを表示できます。 </div> </div> </div><!--modal__inner--> </div><!--modal--> |
css
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
.bt_st{ margin: 0 auto; padding: 10px 0 50px; text-align: center; } .st_box{ background: #eee; height: 200px; margin-bottom: 100px; } .st_modal{ display: none; height: 100vh; position: fixed; bottom: 0; right: 0; left: 0; top: 0; width: 100%; z-index: 999999; } .modal__bg{ background: rgba(0,0,0,0.8); height: 100vh; position: absolute; width: 100%; } .modal__content{ background: #565656; left: 50%; padding: 40px; position: absolute; top: 50%; transform: translate(-50%,-50%); width: 80%; overflow-y: scroll; -webkit-overflow-scrolling: touch; max-height: 80%; color: #fff; } .modal__content a{ color: #fff; font-size: 2em; display: block; position: absolute; right: 20px; top: 10px; text-decoration: none; } @media screen and (min-width: 769px){ .modal__content{ background: #565656; left: 50%; padding: 40px; position: absolute; top: 50%; transform: translate(-50%,-50%); width: 60%; overflow-y: scroll; -webkit-overflow-scrolling: touch; max-height: 80%; color: #fff; } } |
「bt_st」のクラスが付いているボタンの「data-target」と、「st_modal」のクラスが付いている「div」の「id」が一致していないと動きません。
必ず一致させてください。
また、1ページ内で複数使用する場合は、「data-target」「id」の値は変更してください。
1 2 3 4 5 6 7 8 9 10 11 12 |
<div class="bt_st"><a class="js-modal-open" href="" data-target="modal00">詳しく見る</a></div> <div id="modal_out" class="st_modal js-modal"> <div class="modal__bg js-modal-close"></div> <div class="modal__content"> <a class="js-modal-close" href="">×</a> <div class="row"> <div class="col-sm-12"> テキストや画像などを表示できます。 </div> </div> </div><!--modal__inner--> </div><!--modal--> |
「bt_sd」に対応するクラスを追記してください。
ボタンのデザインを変える場合、「bt_sd」を直接編集せず、「bt_sd」に対応するクラスを追記して編集して、その中のaタグを変更するというように編集してください。
html
1 |
<div class="bt_st mo_btst1"><a class="js-modal-open" href="" data-target="">詳しく見る</a></div> |
css
1 2 3 4 5 6 7 8 9 10 11 |
.bt_st.mo_btst1 a{ display: block; background-color: #000; color: #fff; padding: 1rem; transition: .3s; } .bt_st.mo_btst1 a:hover{ text-decoration: none; background-color: #555; } |
html
1 |
<div class="bt_st mo_btst2"><a class="js-modal-open" href="" data-target=""><i class="fas fa-plus"></i></a></div> |
css
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
.bt_st.mo_btst2 a{ display: block; background-color: #000; color: #fff; width: 50px; height: 50px; border-radius: 50%; margin-right: auto; margin-left: auto; } .bt_st.mo_btst2 a i{ line-height: 50px; font-size: 1.4rem; transition: .3s; } .bt_st.mo_btst2 a:hover{ text-decoration: none; } .bt_st.mo_btst2 a:hover i{ transform: rotate(90deg); } |