改变默认选中的背景颜色
::-moz-selection{background:#ff0000;color:#ffffff;}::selection {background:#ff0000;color:#ffffff;}code::-moz-selection {background:#ff0000;color:#ffffff;}code::selection {background:#ff0000;color:#ffffff;}
设置页面禁止选中
/*全局*/html,body{ padding:0px; margin:0px; background:#fff; 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;/**禁止选中文字*/ }
以上代码属于css3所以ie9以下的浏览器可能会出现不兼容的现象。