Home >Web Front-end >CSS Tutorial >How to Adjust :hover Animations for Mobile Device Interaction?
You've encountered an issue where the :hover CSS animation, which expands a panel, doesn't trigger on mobile devices due to the absence of mouse hovering. To address this, you aim to switch the trigger to 'click' or 'touch' when the page width is below 700px.
To achieve this, you can utilize a combination of :hover and :active selectors. By ordering the selectors with :active after :hover in your CSS, you can ensure that touch or click actions on your panel will also trigger the animation. Here's the updated CSS:
.info-slide:hover, .info-slide:active { height: 300px; }
This change ensures that the panel will expand upon hovering or touching on both desktop and mobile devices. To verify its functionality, it's recommended to test it in an actual mobile environment, as simulators may not provide accurate results.
The above is the detailed content of How to Adjust :hover Animations for Mobile Device Interaction?. For more information, please follow other related articles on the PHP Chinese website!