Displaying border upon tapping the icon in a mobile browser

I am facing an issue with an icon that has interactive functionality. When I click on it, a visibility class toggles. However, when I try to interact with it on my phone, a blue marker appears on top of the icon during the process which does not look very professional. You can see this in the image below where the icon is clicked.

https://i.sstatic.net/smtNe.png

This issue does not occur in any of my computer's browsers.

Here is the CSS code for the icon:

width: 22px;
height: 21px;
position: absolute;
top: 0;
right: 0;
margin: 14px;
cursor: pointer;

And here is the HTML code:

<img src="assets/images/heart_empty_icon.png" id="unlike" ng-click="changeLikeIcon()" />

I have created a jsfiddle example with the element here and tested it on my phone with the same result. Can anyone help me understand why this happens and how to solve it?

Answer №1

User interaction

It seems that the user is able to select images just like they would select text on a desktop browser. By including user-select: none; in your CSS code with the appropriate prefixes, you should be able to prevent this.

For more information, check out these resources:

CSS Tricks articles

MDN

Answer №2

Give this a shot

#unlike {
  width: 22px;
  height: 21px;
  position: absolute;
  top: 0;
  left: 0;
  margin: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0); 
  -webkit-tap-highlight-color: transparent; 
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Mobile Chrome allows users to utilize the IFrame player API for enhanced video

Currently, I am working on creating a mobile website where I plan to include some YouTube videos using the IFrame player API (https://developers.google.com/youtube/iframe_api_reference). My main goal is to have the video start playing only after the user ...

Is there a way to trigger two distinct CSS transitions simultaneously with a single click?

Below is a script that rotates two images in opposite directions when clicked. One image spins clockwise while the other spins counter-clockwise. The challenge is that each image requires an individual click to rotate. My goal is to make both images rotate ...

Can you please explain the purpose of the white space in the HTML code?

Currently, I am working on developing a mobile application, and as I start adding styles, I notice a mysterious blank space that seems to be appearing out of nowhere. Can anyone provide any insights or suggestions to help me troubleshoot this issue? https ...

The hyperlink tag doesn't respond to clicks in Safari, yet functions properly in all other web browsers

I'm encountering an issue with my header drop-down menu in Safari—it works perfectly in Chrome, but when I try to open the drop-down menu in Safari, it's unresponsive. Clicking on it does nothing, preventing me from accessing other drop-downs. ...

The CSS styling for a pie chart does not seem to be functioning properly when using jQuery's

https://i.stack.imgur.com/kEAKC.png https://i.stack.imgur.com/03tHg.png After examining the two images above, it appears that the CSS is not functioning properly when I try to append the same HTML code using JavaScript. Below is the snippet of my HTML co ...

Looping through JavaScript to generate HTML code

I have come across a HTML code snippet that looks like this: <div class="content"> <article class="underline"> <a href="incidente.html"><img id="incidente" src="img/buraco.jpg" alt="Incidente" /></a> ...

I'm having trouble getting my button to work with addEventListener while using Ejs and Express. What could

Creating a Twitter-like platform where I can post tweets and have them display on the same page has been quite challenging. I've set up each post to have an Edit button initially hidden with 'display:none'. However, when I try to click on th ...

Move your cursor over the image to activate the effect, then hover over it again to make the effect disappear

Looking to enhance my images with hover effects. Currently, all the images are in grayscale and I'd like to change that so that when you hover over an image, it reverts to full color and remains that way until hovered over again. I've noticed so ...

Javascript - Displaying data retrieved from an external API with JSON

Seeking advice on how to effectively attach JSON values obtained from xhr.response to HTML labels. Any suggestions are appreciated. Thank you. On a different note, does anyone have recommendations for websites that provide concise explanations of basic JS ...

Mastering the art of horizontal alignment in forms

So, within my render function, the following code is used: render() { <div> <form id="one"> <TextField id="t1" ... /> <Button id="b1" /> </form> <div id="empty"><div ...

Mastering the alignment of tab content on Bootstrap 5 to ensure it always displays on the right side

With Bootstrap 5, I've managed to implement tab content that remains visible regardless of the active tab: <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="23414c4c5750575142536 ...

Error message "android.content.res.Resources$NotFoundException in Robolectric 2.4" encountered during testing

Struggling with loading resources in unit tests run from the command line, works fine in IntelliJ. Dependencies: com.android.tools.build:gradle:1.1.3 org.robolectric:robolectric-gradle-plugin:1.0.1 org.robolectric:robolectric:2.4 Project structure (Mul ...

Tips for customizing the cursor to avoid it reverting to the conventional scroll cursor when using the middle click

When you wish to navigate by scrolling with the middle mouse button instead of using the scroll wheel, simply middle-click and your cursor will change allowing for easy scrolling on web pages. Even though I am utilizing style="cursor: pointer" and @click. ...

List created using PHP

After successfully generating a list using PHP with elements selected from a database, I encountered an issue. It seems that when trying to retrieve the index of li elements using jQuery, the indices returned are only odd numbers. For example, clicking on ...

Sometimes CSS Absolute positioning is not adhered to properly

CSS: .layers { position: relative; height: 500px; width: 500px; /* Some -webkit and -moz transformations */ } .layers > div { position: absolute; height: 500px; width: 500px; } .item { position: absolute; width: 5px ...

Prevent certain parts of an element from displaying using CSS

By utilizing the CSS3 property clip-path, I am able to easily clip elements so that only a specified area remains visible. While this feature is useful, I'm wondering if there is a method to exclude an area so that everything except the specified path ...

How can I remove the excess space above and below tables that have differing numbers of rows?

Forgive me if my question seems basic or if there are any errors in it. I am new to HTML/CSS and collaboration tools like this platform. While I understand that these are not your typical HTML tables, they are what I've found to be the most effective ...

Let's apply some CSS to the font style within the body

I've been incorporating a "footer.php" page into all other pages of my website. This footer showcases the site's name at the bottom of the screen and uses a custom font loaded with @font-face. Initially, I had something like this placed inside t ...

How come JavaScript variables are able to persist on JQuery Mobile multi-page templates on desktop browsers, but not on mobile browsers?

My website was created using the jQuery Mobile multi-page template. While testing it on Chrome desktop, I noticed that my JavaScript variables (comics and checkedItems) retain their values when navigating between pages. However, on mobile devices, these ar ...

uniformly distribute the list items on the horizontal navigation bar

Does anyone know how to properly space out a ul in a navigation bar, with 5px padding on the right and left and the text evenly spaced in between? body { background: #ffffff; text-align: center; font-family: helvetica, arial, san ...