更改悬停时元素的所有实例的属性(CSS) [英] Change property of all instances of element on hover (CSS)

查看:75
本文介绍了更改悬停时元素的所有实例的属性(CSS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组文章元素,使用第n个子元素,奇数元素的背景色设置为蓝色,其余的设置为红色。

I have a group of article elements, using nth-child the odd ones have their background-colors set to blue and the rest red.

参见此处: http://jsfiddle.net/ 8KFwh / 4 /

我希望将鼠标悬停在其中的所有文章元素上时,将其背景颜色更改为白色。此外,您将鼠标悬停在上方时,其背景颜色将变为绿色,除一个以外,所有文章元素都将变为白色。

I'm looking to be able to change the background color of all the article elements to white when you hover over just one of them. Furthermore the one that you hover over will change it's background-color to green, leaving all article elements white except for one.

我知道在JS中很容易做到,但是我想知道是否有可能在CSS中做到。

I know it would be easy to do in JS but I'm interested to know if it's possible to do in CSS.

谢谢,欢迎您提供任何帮助:)

Thanks, any help is welcome :)

推荐答案

您的意思是这样吗? http://jsfiddle.net/mkoistinen/8KFwh/5/

You mean like this? http://jsfiddle.net/mkoistinen/8KFwh/5/

这篇关于更改悬停时元素的所有实例的属性(CSS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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