手机
当前位置:查字典教程网 >网页设计 > Div+Css教程 >通过CSS规则禁止选中文字的实现代码
通过CSS规则禁止选中文字的实现代码
摘要:语法Formalsyntax:none|text|all|element(-prefix-)user-select:none;(-prefi...

语法

Formal syntax: none | text | all | element

(-prefix-)user-select: none;

(-prefix-)user-select: text;

(-prefix-)user-select: all;

(-prefix-)user-select: element;

示例

.row-of-icons {

-webkit-user-select: none; /* Chrome all / Safari all */

-moz-user-select: none; /* Firefox all */

-ms-user-select: none; /* IE 10+ */</p> <p> /* No support for these yet, use at own risk */

-o-user-select: none;

user-select: none;

}

IE兼容性

目前在IE 10以及IE 10以上版本的浏览器可以使用-ms-user-select这个规则,但在更早版本的IE,我们只能通过javascript实现禁止选中文本:

$(el).attr('unselectable','on')

.css({'-moz-user-select':'-moz-none',

'-moz-user-select':'none',

'-o-user-select':'none',

'-khtml-user-select':'none', /* you could also put this in a class */

'-webkit-user-select':'none',/* and add the CSS class here instead */

'-ms-user-select':'none',

'user-select':'none'

}).bind('selectstart', function(){

return false;

});

【通过CSS规则禁止选中文字的实现代码】相关文章:

CSS3制作ajax loader icon实现思路及代码

css强制文字不换行实现代码

利用CSS实现禁止双击选择页面内容的实例展示

巧用CSS3 border实现图片遮罩效果代码

CSS各种文字对齐方式代码

CSS常用中文字体大全

CSS自动控制图片大小的代码

CSS学习中的瓶颈

在div底部显示背景图片实现代码

有关首行首字下沉的实现原理及代码

精品推荐
分类导航