如果一个元素悬停,则更改其他元素的 CSS 值
我有一些由 .card
框元素显示的社交媒体链接。现在我想让如果没有 .card
悬停,不透明度将保持在 1
但如果有一个 .card
悬停,则每个除实际悬停的卡片外,其他卡片现在应将其不透明度更改为 0.7
。我的 .card
只有类 cardsocialsElement
。
我已经尝试过这个
.socialsElement.card:hover .card:not(:hover) {
opacity: 0.5;
}
但不起作用
I have a few social-media links displayed by .card
box-elements. Now I want to make that if no .card
is hovered, the opacity will just stay at 1
but if one .card
is hovered, every card except for the one that's actually being hovered, should now change its opacity to 0.7
. My .card
s just have the classes card socialsElement
.
I've already tried this
.socialsElement.card:hover .card:not(:hover) {
opacity: 0.5;
}
but doesn't work
(Expectation)
If none is being hovered
If One card is being hovered
Live Preview
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你就快到了:
You're almost there: