悬停在其他元素的CSS? [英] hover on other element CSS?

查看:104
本文介绍了悬停在其他元素的CSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我悬停时,为什么.a的背景颜色不会改变? .b?

Why does the background-color of .a does not change when I hover? .b?

CSS

CSS

.a {
    color: red;
}

.b {
    color: orange;
}

.b:hover .a {
    background-color: blue;
}

HTML $ b

HTML

<div id="wrap">
    <div class="a">AAAA
    <div class ="b">BBBB</div>
    </div>
</div>

http://jsfiddle.net/2NEgt/323​​/

推荐答案

因为 .a 不是后代或在 .b 之后/之内,这是它的工作条件

Because .a is not descendent or comes after/inside of .b which is condition to work for it

工作

for example if you inverse it, since .b is descendent of .a, it will work

.a:hover .b {
    background-color: blue;
}

这篇关于悬停在其他元素的CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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