開發h5 app中突然發現在手機上長按文本會出現復制粘貼菜單,只要是文本長按都會出現這種情況確實有些不太符合交互,為此特意去翻了一下博客,得到了已下解決方案;
將所有元素的系統默認菜單禁用掉
1 *{ 2 -webkit-touch-allout:none;//禁用系統默認菜單 3 user-select:none;//不允許用戶選中 4 -webkit-user-select:none; 5 -moz-user-select:none; 6 -ms-user-select:none; 7 }
但是呢,這樣寫的話在ios上又會出現輸入框無法輸入的問題,所以要加上以下代碼
1 input,textarea{ 2 -webkit-user-select:text;//允許用戶選中文本 3 }
好了,完美解決問題