前提・実現したいこと
iOSモバイルデバイスでタップ後動作
発生している問題・エラーメッセージ
Android、WindowsのChromeでは問題なく動作していますが、iOS モバイルデバイスでは
以下のボタンの動作が不安定です。(iPhone678Xでは3度タップすれば動作しています)
該当のソースコード
HTML
1<ul> 2 <li> 3 <li style="width: 200px;padding-left: 5px;">Menu</li> 4 <li style="width: 350px;"></li> 5 <li> 6 <div class="fixed_btn"> 7 <div class="switch"> 8 <label class="switch__label"> 9 <input id="is" name="check" type="checkbox" class="switch__input" onClick="jump()" /> 10 <span class="switch__content"></span> 11 <span class="switch__circle"></span> 12 </label> 13 </div> 14 </div> 15 </li> 16 </li> 17</ul>
CSS
1.fixed_btn { 2 bottom: 10px; 3 right: 10px; 4 padding: 6px 0px; 5} 6 7.switch__label { 8 width: 50px; 9 position: relative; 10 display: inline-block; 11 height: 30px; 12} 13 14.switch__content { 15 display: block; 16 cursor: pointer; 17 position: relative; 18 border-radius: 50px; 19 height: 31px; 20 overflow: hidden; 21} 22 23.switch__content:before { 24 content: ""; 25 display: block; 26 position: absolute; 27 width: calc(100% - 3px); 28 height: calc(100% - 3px); 29 top: 0; 30 left: 0; 31 border: 1.5px solid #E5E5EA; 32 border-radius: 30px; 33 background-color: #fff; 34} 35 36.switch__content:after { 37 content: ""; 38 display: block; 39 position: absolute; 40 background-color: transparent; 41 width: 0; 42 height: 0; 43 top: 50%; 44 left: 50%; 45 border-radius: 30px; 46 -webkit-transition: all .5s; 47 -moz-transition: all .5s; 48 -ms-transition: all .5s; 49 -o-transition: all .5s; 50 transition: all .5s; 51} 52 53.switch__input { 54 cursor: pointer; 55 display: none; 56} 57 58.switch__circle { 59 display: block; 60 top: 2px; 61 left: 2px; 62 position: absolute; 63 -webkit-box-shadow: 0 2px 6px #999; 64 box-shadow: 0 2px 6px #999; 65 width: 27px; 66 height: 27px; 67 -webkit-border-radius: 20px; 68 border-radius: 20px; 69 background-color: #fff; 70 -webkit-transition: all .5s; 71 -moz-transition: all .5s; 72 -ms-transition: all .5s; 73 -o-transition: all .5s; 74 transition: all .5s; 75} 76 77.switch__input:checked~.switch__circle { 78 left: 21px; 79} 80 81.switch__input:checked~.switch__content:after { 82 background-color: #568fea; 83 top: 0; 84 left: 0; 85 width: 100%; 86 height: 100%; 87 -webkit-transition: 1s; 88 -moz-transition: 1s; 89 -ms-transition: 1s; 90 -o-transition: 1s; 91 transition: 1s; 92} 93 94ul { 95 list-style: none; 96}
js
1function jump() { 2 $(function() { 3 4 $('input[name="check"]').change(function() { 5 var is = $('#is').prop('checked'); 6 if (is) { 7 setTimeout(function() { 8 window.alert('Worked!!'); 9 }, 200); 10 11 } 12 }) 13 }); 14}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。