通過css實現頁面文字不能被選中
(推薦教程:CSS教程)
.cannotselect { -webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
css介紹
user-select
說明
控制選取能否被選擇.
該特性是非標準的,請盡量不要在生產環(huán)境中使用它!
Formal syntax: none | text | all | element
none:元素內的文字及其子元素將不會被選中
text:用戶可以選中文字
all:在一個HTML編輯器中,當雙擊子元素或者上下文時,那么包含該子元素的最頂層元素也會被選中。
element:火狐和IE中有效. Enables selection to start within the element; however, the selection will be contained by the bounds of that element.
瀏覽器兼容性
-webkit-touch-callout
說明
這個CSS 屬性禁用了默認的callout展示, callout是指當觸摸并按住一個元素的時候出現的提示。
當在iOS上一直按住一個目標元素時,Safari會展示一個關于這個鏈接的callout信息。webkit-touch-callout屬性允許禁用掉這一行為。
-webkit-touch-callout 屬性最早在 iOS 2.0 上實現,后來被添加到WebKit
允許的值
default:此值表示顯示默認的callout
none:此值表示禁用callout
瀏覽器兼容性