CSS禁止选中文本

<p class="noselect">
Unselectable text.
</p>

<style>
.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 */
}
</style>

在 IE < 10 和Opera < 15中需要在需要禁止选中的元素上面添加一个属性:

unselectable="on",否则可能不会生效。

posted @ 2017-11-10 10:59  Jakeylove3  阅读(218)  评论(0编辑  收藏  举报