css 让文本不被选定之

2021-03-12 14:19 jianzhan
他在ie下也能选定文本,可是选定别的目录,不容易选定文本,原先它是在不一样div中,属于不一样的范畴,而朋友是放在同1个table中,自然会选定。
而在firefox下,文本不容易被选定,查询google calender的css,原先也有-moz-user-select这个特性,很好玩!
最终选用1个了js方式,即onselectstart=function{return false;},不让网页页面开展挑选,呵呵,这是许多网站不让拷贝选用的方式。

Summary
-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.

Syntax
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!
</span>

Notes

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

-moz-user-focus
-moz-user-input
-moz-user-modify

css中的 “-moz-user-select”和“-khtml-user-select”特性是什麽意思?和它们的用法?
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF⑻">
<title></title>
<style type="text/css">
h1{
-moz-user-select:-moz-none;
}
</style>
</head>
<body>
<h1>这里在firefox中会显示信息不一样</h1>
<pre>
屏蔽挑选的款式界定:-moz-user-select特性(只适用ff)。
特性有3个特性值:
1、 none:用none,子元素全部的文本都不可以挑选,包含input键入框中的文本也不可以挑选。
2、 -moz-all:子元素全部的文本都可以以被挑选,可是input键入框中的文本不能以被挑选。
3、 -moz-none:子元素全部的文本都不可以挑选,可是input键入框中的文本以外。
IE访问器下是根据 onselectstart=”javascript:return false;”恶性事件来完成该作用。
</pre>
</body>
</html>
-khtml-是iPhone的那个访问器的 仿佛如今应用-webkit-user-select: none