【发布时间】:2013-03-23 04:36:38
【问题描述】:
背景
希望禁用突出显示表格的第一列。
HTML 源代码
<table>
<tbody>
<tr><td class="unselectable" unselectable="on"><button value="1" unselectable="on" class="unselectable"><div unselectable="on" class="unselectable">✘</div></button></td><td>Row 1</td></tr>
<tr><td class="unselectable" unselectable="on"><button value="2" unselectable="on" class="unselectable"><div unselectable="on" class="unselectable">✘</div></button></td><td>Row 2</td></tr>
<tr><td class="unselectable" unselectable="on"><button value="3" unselectable="on" class="unselectable"><div unselectable="on" class="unselectable">✘</div></button></td><td>Row 3</td></tr>
</tbody>
</table>
CSS 源代码
*.unselectable {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
user-select: none;
}
小提琴
问题
当用户在表格上选择并拖动鼠标按钮时,按钮文本 (✘) 会突出显示(不希望出现的行为)。当用户复制和粘贴值时,值 (✘) 不包括在内(期望的行为)。
为了澄清,这是当前的行为(不希望的):
下图显示了在表格上拖动鼠标后所需的行为:
大多数用户可能不会在意,但这是一种略微误导的用户体验。无论用户突出显示文本并复制它,都希望复制所有突出显示的文本。通过添加unselectable 类,按钮的 (✘) 值会突出显示,但不会被复制。用户根本不应该能够突出显示(选择)(✘)因为它被设置为unselectable。
环境
我在 Xubuntu 上使用 Firefox 19.0.2,但我寻求跨浏览器的解决方案。
问题
防止用户突出显示第一列(包含按钮)的跨浏览器方法是什么?
相关
- How to disable text selection highlighting using CSS?
- Is there a way to make a DIV unselectable?
- Imitate "onselectstart=return false" using CSS or other non-JS approach?
- http://www.mindfiresolutions.com/Using-of-onselectstart-and-its-alternative-for-Firefox-239.php
- http://therelentlessfrontend.com/2010/02/13/how-to-disable-text-selection-in-a-table/
【问题讨论】:
-
我不太确定你的问题是什么?您不想在单击时出现蓝色突出显示吗?
-
@MitchellLayzell 尝试复制并粘贴他的表格,你就会明白他的意思。
标签: css select html-table cross-browser highlight