項目中可能會遇到禁止鼠標選中和複製的需求:
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
not supported by any browser */
}
在 IE < 10 和Opera < 15中我們需要在需要禁止選中的元素上面添加一個屬性
unselectable="on",否則可能不會生效哦~不過現代瀏覽器如果不是非得兼容一些老的瀏覽器也可以不加。