I’m using Boostrap 4 to build a Web. A simple code such as below:
JavaScript
x
4
1
<div class="col-12 p-2" id="Maincourse">
2
<h1 class="m-0">Main course</h1>
3
</div>
4
I use my Android Chrome Browser(version 80.0.3987.149) click on the text, it will highlighted the text and popup google search.
How can i disable it? I Don’t want to set user-select: none
because I need to let the user highlight the text when long press.
Advertisement
Answer
JavaScript
1
7
1
.disable-select {
2
user-select: none; /* standard */
3
-moz-user-select: none; /* firefox specific */
4
-webkit-user-select: none; /* Chrome, Opera and Safari*/
5
-ms-user-select: none; /* IE, ms-edge */
6
}
7
Source1: https://www.w3schools.com/cssref/css3_pr_user-select.asp
Source2: https://developer.mozilla.org/en-US/docs/Web/CSS/user-select
version compatibility
desktop:
JavaScript
1
7
1
Chrome: 54+
2
Firefox: 69+
3
Opera: 41+ (15+ with vendor prefix)
4
Safari: 3+
5
MS Edge: 12+
6
IE: 10+
7
mobile
JavaScript
1
6
1
Chrome for Android: 54+
2
Android web-view: 54+
3
Firefox for Android: 4+
4
Opera for Android: 14+
5
Safari on IOS: 3+
6
refer to the sources for more info and version compatibility.