问题:在iphone端,在输入框点击时,出现光标偏移,输入是正常的
分析:iphone对fix布局有兼容支持问题
解决:
css:
body.modal-open { position: fixed; 100%; }
js:
<script> /** * ModalHelper helpers resolve the modal scrolling issue on mobile devices * https://github.com/twbs/bootstrap/issues/15852 * requires document.scrollingElement polyfill https://github.com/yangg/scrolling-element */ var ModalHelper = (function(bodyCls) { var scrollTop; return { afterOpen: function() { scrollTop = document.scrollingElement.scrollTop; document.body.classList.add(bodyCls); document.body.style.top = -scrollTop + 'px'; }, beforeClose: function() { document.body.classList.remove(bodyCls); // scrollTop lost after set position:fixed, restore it back. document.scrollingElement.scrollTop = scrollTop; } }; })('modal-open'); // function openModal() { // document.getElementById('modal').style.display = 'block'; // ModalHelper.afterOpen(); // } // function closeModal() { // ModalHelper.beforeClose(); // document.getElementById('modal').style.display = 'none'; // } // var btns = document.querySelectorAll('.js-open-modal'); // btns[0].onclick = openModal; // btns[1].onclick = openModal; // document.querySelector('#modal').onclick = closeModal; </script>