Solving the Non-Functioning :active Pseudo-Class for :active Links in Mobile Safari
Touchstart Event
Add the ontouchstart event to the
element:<body ontouchstart=""> ... </body>
This enables the trigger of the :active pseudo-class when tapping on any element within the page.
Fastclick Library
Alternatively, utilize the Fastclick JavaScript library. This library enhances the responsiveness of click events on touch devices and also addresses the :active pseudo-class issue.
The above is the detailed content of Why Doesn\'t the `:active` Pseudo-class Work on Mobile Safari Links, and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!