如何使:focus,:active与:hover相同 [英] How make :focus, :active be the same as :hover

查看:86
本文介绍了如何使:focus,:active与:hover相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有简单的方法可以使:focus& :active表现为:hover?

Is there any simple way make :focus & :active behave as :hover?

通常我写:

.class a:hover, .class a:active, .class a:focus {...}

但是我只想编写一个:hover规则和:focus& :active看起来一样

But i would like to write just a single :hover rule and :focus & :active will look the same

.class a:hover {...}

推荐答案

CSS2/3中目前没有更好的方法.

There is currently no better way to do so in CSS2/3.

但是,您可能想使用 cssnext 来使用 :matches() 语法.

However, you might want to use cssnext to use the @custom-selectors and :matches() syntax today.

使用自定义选择器:

@custom-selector :--enter :hover, :focus, .active;

a:--enter { ... }

With:matches()

With :matches()

a:matches(:hover, :focus, .active) { ... }

这篇关于如何使:focus,:active与:hover相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆