蘋果ios瀏覽器踩過的坑

1.click事件;css

要在css中加上cursor: pointer;ios的點擊纔有效html

2.margin-bottom問題;ios

在ios上,最後一個元素加margin-bottom無效。web

3.時間轉化問題iphone

由時間轉時間戳時ide

new Date('2019-07-3 11:22:32').getTime(); //蘋果顯示NANspa

在ios上 new Date("2019-07-3 11:22:32".replace(/-/g,'/')).getTime(); //問題解決code

蘋果不識別-。要寫成 /htm

4.position: fixed中的input框聚焦軟鍵盤彈出,IOS下會有光標錯位問題事件

// IOS 9 實測有效
html, body {
  -webkit-overflow-scroll: touch;
}

5.滾動穿透問題(實測的此方法兼容性最好,兼容IOS,實測iphone X也有效)

body.overflowHide {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
}

彈窗展開時給body增長class="overflowHide",同時記錄

const top = window.scrollY;

動態設置top爲-${top}px
彈窗收起時移除該class,設置top爲0,調用window.scrollTo(0, top)恢復原滾動位置

相關文章
相關標籤/搜索