Enabling `:active` styling in mobile device

Thomas Mak wrote at 2018-09-20.


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:



no comments yet.

Please login to chat.