怎样让css不选中
导读:想要让CSS不选中,有以下几种方法:1.使用user-select属性,将元素的选择能力设置为none,如下:.no-select {-webkit-user-select: none;-moz-user-select: none;-ms-...
想要让CSS不选中,有以下几种方法:
1.使用user-select属性,将元素的选择能力设置为none,如下:
.no-select {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
2.使用JavaScript禁止选择文本:
document.onselectstart = function () {
return false;
}
;
3.针对特定元素使用CSS的::selection伪类,将选中样式修改为无样式:
.no-select::selection {
background: transparent;
color: inherit;
}
需要注意的是,以上方法并不能完全阻止用户选择元素,只是降低了用户选择的可能性。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: 怎样让css不选中
本文地址: https://pptw.com/jishu/341231.html
