不可选择的文字(链接)

时间:2016-06-01 09:48:36

标签: javascript html css

我有以下代码:Fiddle



a {
  color: #000;
  text-decoration: none
}

<!- I want the link "JS Fiddle" to be not selectable. If I can't make it unselectable at least make it look like an image (select all the text at once)? -->

<a href="https://jsfiddle.net/">JS Fiddle</a>
<br>
<img draggable="false" src="http://i.imgur.com/qdYd7hK.png">
&#13;
&#13;
&#13;

我想要实现的目的是让链接看起来就像选择它一样。

&#34; JS Fiddle&#34;使用1个蓝色选项,如图像而不是每个字符,就像普通文本一样。

原因是因为我想要一个简单的文字(链接),因为它是网站的标识。

2 个答案:

答案 0 :(得分:3)

您可以使用Prevent drop of list item in JqueryUI sortable,以便无法选择元素和子元素(应用CSS规则的文本)的文本。

a {
  -webkit-touch-callout : none;     /* iOS Safari */
  -webkit-user-select   : none;     /* Chrome/Safari/Opera */
  -khtml-user-select    : none;     /* Konqueror */
  -moz-user-select      : none;     /* Firefox */
  -ms-user-select       : none;     /* Internet Explorer/Edge */
}

a {
  color: #000;
  text-decoration: none
}
a {
  -webkit-touch-callout: none;
  /* iOS Safari */
  -webkit-user-select: none;
  /* Chrome/Safari/Opera */
  -khtml-user-select: none;
  /* Konqueror */
  -moz-user-select: none;
  /* Firefox */
  -ms-user-select: none;
  /* Internet Explorer/Edge */
  user-select: none;
  /* Non-prefixed version, currently not supported by any browser */
}
<!- I want the link text "JS Fiddle" to not be selectable. If I can't make it unselectable at least make it look like an image (select all the text at once)? -->
<a draggable="false" href="https://jsfiddle.net/">JS Fiddle</a>
<br>
<img draggable="false" src="http://i.imgur.com/qdYd7hK.png">

答案 1 :(得分:-1)

你可以使用

a{
   pointer-events: none;
   cursor: default;
}

a{
   color: #000;
   text-decoration: none;
   pointer-events: none;
   cursor: default;
}
<!- I want the link "JS Fiddle" to be not selectable. If I can't make it unselectable at least make it look like an image (select all the text at once)? -->

<a href="https://jsfiddle.net/">JS Fiddle</a>
<br>
<img draggable="false" src="http://i.imgur.com/qdYd7hK.png">