CSS悬停在某物上,并有一个完全不同的div改变其属性 [英] CSS Hover over something and have a completely different div change its attribute
本文介绍了CSS悬停在某物上,并有一个完全不同的div改变其属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码
html
< div class =a> LOREM IPSUM< / div>
< div class =boxhighlight>< / div>
css
.a:hover,.boxhighlight
{
background-color:black;
}
我想要发生的是当用户将鼠标悬停在单词lorem ipsum ,div boxhighlight将改变其背景颜色
有办法吗?
p>
解决方案
使用像这样
< div class =a> LOREM IPSUM< / div>
< div class =boxhighlight> asdf< / div>
您的css
.a:hover〜.boxhighlight {
background-color:black;
color:white;
}
查看您的参考
查看此小提琴中的示例
im trying to write a code where you hover over a div and have a completely different div change its effect
heres my code
html
<div class="a">LOREM IPSUM</div>
<div class="boxhighlight"></div>
css
.a:hover, .boxhighlight
{
background-color:black;
}
what i want to happen is that when the user hovers over the word lorem ipsum, the div boxhighlight will change its background color
is there a way to do this?
thanks
解决方案
Use like this
<div class="a">LOREM IPSUM</div>
<div class="boxhighlight" >asdf</div>
Your css
.a:hover ~ .boxhighlight {
background-color:black;
color: white;
}
See this for your Reference
See example in this Fiddle
这篇关于CSS悬停在某物上,并有一个完全不同的div改变其属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文