Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable blue selection on double click, in table header?

Tags:

html

css

I have followed table header structure:

<th>
 <a ng-click="sort_by(order)" style="color: #555555;">
   <span ng-transclude="">
       <span class="ng-scope">Some text</span>
   </span>
   <i class="icon-chevron-down"></i>
 </a>
</th>

The problem is, when I double click on header link, the background is selected (blue color) and seems messy.

How to avoid this behavior?

Thanks,

enter image description here

like image 791
snaggs Avatar asked Oct 14 '25 16:10

snaggs


1 Answers

You could use user-select:none, which will disable selection of the th element.

jsFiddle example - try highlighting the element.

th {
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

Support for this property can be found here.


If you are concerned about support, you could alternatively use ::selection to change the color from blue to transparent. This method has a little more support.

jsFiddle example - try highlighting the element.

th::selection {
    color:transparent;
}
th::-moz-selection {
    color:transparent;
}

It is supported in IE9. Reference here.

like image 185
Josh Crozier Avatar answered Oct 17 '25 05:10

Josh Crozier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!