css 让文本不被选定之

2021-03-12 14:19 jianzhan
而在firefox下,文本不容易被选定,查询google calender的css,原先也有-moz-user-select这个特性,很好玩!
最终选用1个了js方式,即onselectstart=function{return false;},不让网页页面开展挑选,呵呵,这是许多网站不让拷贝选用的方式。

-moz-user-select is a Mozilla property extension to CSS that is used to determine whether or not an element may have its content selected.

Media: interactive

Possible uses include: prohibiting the selection of content in attempts to reduce blatant copying.

TARGET_ELEMENT{-moz-user-select: none;}Legal Values
Value Description inherit Inherit the value from the parent element. none None of the content may be selected. text Only the text within the element may be selected. element A single element may be selected (from many). elements Multiple elements may be selected. all The contents must either be selected in entirety or none at all. toggle The contents are selected "following a standard toggling content model" [1]. tri-state unknown -moz-all unknown

Usage Examples

This sample code provides a simple "Hello, World!" text which prevents the user from selecting the content:

<span style="-moz-user-select: none;">
Hello, World!


This property is similar to the user-select property of CSS3.

When the 'none' value was applied to a heading element the content could still be selected.

According to the W3C, the "User agent's default style sheet may override this value. For example, user agents typically do not allow selection of the contents of a BUTTON element. [2] As the -moz-user-select was designed to mimic the user-select property, the same applies.

Specification Conformance

Doesn't conform to CSS standards; A Mozilla CSS Extension.

Browser Compatibility

Netscape 6+
Mozilla 0.6+
Firefox 1.0+

See Also


css中的 “-moz-user-select”和“-khtml-user-select”特性是什麽意思?和它们的用法?
<html lang="en-US">
<meta charset="UTF⑻">
<style type="text/css">
1、 none:用none,子元素全部的文本都不可以挑选,包含input键入框中的文本也不可以挑选。
2、 -moz-all:子元素全部的文本都可以以被挑选,可是input键入框中的文本不能以被挑选。
3、 -moz-none:子元素全部的文本都不可以挑选,可是input键入框中的文本以外。
IE访问器下是根据 onselectstart=”javascript:return false;”恶性事件来完成该作用。
-khtml-是iPhone的那个访问器的 仿佛如今应用-webkit-user-select: none