iphone 端 ipunt輸入框光標偏移

問題:在iphone端,在輸入框點擊時,出現光標偏移,輸入是正常的javascript

分析:iphone對fix佈局有兼容支持問題css

解決:java

css:git

body.modal-open {
    position: fixed;
    width: 100%;
}

 

js:github

<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>

 

 

 

相關文章
相關標籤/搜索