HTML How can I prevent someone highlighting text within divs?
Firstly yes I have found this link:
Is there a way to make text unselectable on an HTML page?
but it doesn't seem to work for me. I have lots of divs containing text, making a customised table. When a user uses ctrl and clicks on multiple rows sometimes the table content gets highlighted too. Then this causes a problem when I wish to scroll across the开发者_StackOverflow中文版 overflow of the table.
You can use this CSS:
.unselectable {
user-select: none;
}
Use CSS to solve this problem:
body {
-webkit-user-select: none; /* Webkit */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE 10 */
/* Currently not supported in Opera but will be soon */
-o-user-select: none;
user-select: none;
}
精彩评论