Загрузка видео...

Не удалось загрузить видео

На главную

How to use the :where CSS selector to solve specificity problems ↓

61,881 просмотров • 1 год назад •via X (Twitter)

Комментарии: 10

Фото профиля Sebastiano Guerriero
Sebastiano Guerriero1 год назад

As a general rule, I try to keep CSS selector specificity low. It simplifies code maintenance. In this example, you might use: '.cd-calendar-date:hover:not(.cd-calendar-date--selected) {}' to achieve the same result, but it creates high specificity, leading to potential override issues. The :where selector is handy because it lowers the specificity.

Фото профиля Shay Punter
Shay Punter1 год назад

Honestly the :where operator is such an underrated operator, I am surprised that more people aren't using it. Lets you be very specific in terms of what you can style, very useful for use-cases like above!

Фото профиля Sebastiano Guerriero
Sebastiano Guerriero1 год назад

💯

Фото профиля Alireza Bashiri
Alireza Bashiri1 год назад

you're saving an entire generation from @tailwindcss

Фото профиля Oath
Oath1 год назад

smart way of using :where, thanks for the tip

Фото профиля Alex K
Alex K1 год назад

Great advice

Фото профиля ƨergey
ƨergey1 год назад

Nice but hard to support, unless you comment this shit 😀 Prefer to have .active class

Фото профиля Sebastiano Guerriero
Sebastiano Guerriero1 год назад

You’d still need the .active class (.cd-calendar-date—selected in this example). The :where operator only saves you some code because you wouldn’t need to override .class:hover with .active:hover

Фото профиля Eric Fortis
Eric Fortis1 год назад

I rather .cd-calendar-date--selected, .cd-calendar-date--selected:hover {}

Фото профиля Sebastiano Guerriero
Sebastiano Guerriero1 год назад

You can do that, but you’d need to override the .cd-calendar-date:hover style.

Похожие видео