jay*_*t55 0 html css layout html5 css3
我有3个div.当我将鼠标悬停在"主要"/"第一"div上时,我想改变其中2个div中的一些东西.我真的,真的试图避免使用Javascript/jQuery,这里.
我很确定这可以做到,我依旧记得刚才读到这篇文章,但我再也找不到这个链接而且之前的搜索没有帮助,可能是因为我可能没有使用正确的术语.
这是代码:HTML:
<div id=one></div>
<div id=two></div>
<div id=three></div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#one{background-color:blue;width:50px;height:50px;float:left;}
#two{background-color:green;width:50px;height:50px;float:left;}
#three{background-color:red;width:50px;height:50px;float:right;}
#one:hover > #two + #three { background-color: yellow; }
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?当我将鼠标悬停在第一个div上时,如何让其他两个 div改变颜色?
你的意思是这样吗?
#one:hover ~ #two ,
#one:hover ~ #three
{ background-color: yellow; }
Run Code Online (Sandbox Code Playgroud)
问题是这>意味着它是直接后代选择器和选择器的组合+将无法工作.