Home >Web Front-end >HTML Tutorial >CSS3改变页面默认选中背景颜色及设置页面禁止全选或局部选择_html/css_WEB-ITnose

CSS3改变页面默认选中背景颜色及设置页面禁止全选或局部选择_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:34:491432browse

改变默认选中的背景颜色 

::-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以下的浏览器可能会出现不兼容的现象。  

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn