Enabling `:active` styling in mobile device

Thomas Mak wrote at 2018-09-20.

#mobile-web

The following JavaScript enables the :active style.

document.ontouchstart = function() {};

Then, we set the button to have transparent tap highlight:

.button {
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

See the Pen jvXWrM by Thomas Seng Hin Mak (@makzan) on CodePen.

Try in mobile:

https://s.codepen.io/makzan/debug/jvXWrM

Comments

no comments yet.