在ios端默認(rèn)的長(zhǎng)按選擇,可以對(duì)文字進(jìn)行復(fù)制粘貼。但是在實(shí)際開發(fā)中,針對(duì)一些按鈕一般要避免長(zhǎng)按時(shí)彈出選中文字,或者一些罩層要避免彈出。 這篇文章通過css3實(shí)現(xiàn)禁止ios端長(zhǎng)按復(fù)制選中文字的方法。 css代碼如下: *{ -webkit-touch-callout:none; /*系統(tǒng)默認(rèn)菜單被禁用*/ -webkit-user-select:none; /*webkit瀏覽器*/ -khtml-user-select:none; /*早期瀏覽器*/ -moz-user-select:none;/*火狐*/ -ms-user-select:none; /*IE10*/ user-select:none; } Pexelshttps://www./sites/73241.html 天堂圖片網(wǎng)https://www./sites/73243.html 但是IOS上出現(xiàn)input、textarea不能輸入,因此將使用-webkit-user-select:auto;如下: input,textarea { -webkit-user-select:auto; /*webkit瀏覽器*/ margin: 0px; padding: 0px; outline: none; } 這樣就避免了蘋果手機(jī)上會(huì)導(dǎo)致input輸入框不能聚焦從而不能輸。當(dāng)然一般不要輕易使用通配符*{}的方式,我們可以給定對(duì)應(yīng)class名稱。 |
|