Eugene Khristo
Eugene Khristo

Reputation: 79

Strange CSS ''overlay effect'' on Mobile Browsers

I've just learned to make animation with CSS. On Desktop Chrome everything is OK. But when I checked it out on Chrome for Android - there's some strange overlay effect when clicking.

Code

.btn {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  display: block;
  position: relative;
  margin: 0 auto;
  outline: none;
  border: none;
  background-color: #ff8800;
  padding: 25px 65px;
  font-size: 25px;
  text-transform: uppercase;
  border-radius: 25px;
  box-shadow: 0 8px #ff6600;
  cursor: pointer;
  top: 0;
  transition: all .3s;
}

.btn:hover {
  top: 3px;
  box-shadow: 0 5px #ff6600;
}

.btn:active {
  top: 8px;
  box-shadow: none;
}
<button class="btn">Click Me!</button>

Screenshots:

Normal state:

enter image description here

When clicking:

enter image description here

How I can get rid of this strange overlay on mobile browser? Thanks.

Upvotes: 3

Views: 928

Answers (1)

Teo Dragovic
Teo Dragovic

Reputation: 3518

Add -webkit-tap-highlight-color: transparent; to your .btn class (or even globally to body if you want to prevent this on all clickable elements).

Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-tap-highlight-color

Demo: https://codepen.io/teodragovic/pen/yjYLaM?editors=0100#0

Upvotes: 3

Related Questions