使文本不可选 [英] Making text unselectable

查看:105
本文介绍了使文本不可选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,在使用滚动条和HTML5的东西,我开始注意到一个恼人的趋势。如果我的元素附近有文本被拖动(例如,视频的滚动条,滚动条,用户可以点击并拖动的任何东西),附近的文本将被选中,就好像我没有使用控件,只是拖动

So, while playing with scrollbars and stuff in HTML5, I'm starting to notice an annoying trend. If I have text near my element that's being dragged (say, a scrub bar for a video, scroll bar, anything a user would click and drag), nearby text will get selected, as if I'm not using a control, just dragging over the page.

这是非常讨厌的,我似乎找不到正确的字符串在谷歌搜索,以确定是否可以做某些元素unselectable。

This is terribly annoying, and I can't seem to find the right string to search for on google to figure out if it's possible to make certain elements "unselectable".

任何人都知道如何做到这一点?

Anyone know how to do this?

推荐答案

它因浏览器而异。这些CSS属性将面向基于WebKit和Gecko的浏览器以及任何支持用户选择的任何浏览器:

It varies per browser. These CSS properties will target WebKit and Gecko-based browsers, as well as any future browsers that support user-select:

user-select: none;
-webkit-user-select: none;
-moz-user-select: none;

这篇关于使文本不可选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆