Home >Web Front-end >CSS Tutorial >CSS hover changes the styles of child elements and other elements

CSS hover changes the styles of child elements and other elements

高洛峰
高洛峰Original
2017-03-01 15:11:382545browse

css hover changes the style of child elements and other elements

+ indicates the next level element, > indicates child elements

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>

<style>
    #a {color : #FFFF00;}

    #a:hover + #c{color : #00FF00;}
    #a:hover + #c > #b{color : #0000FF;}
</style>
<div id=&#39;a&#39;>元素1

</div>
<div id=&#39;c&#39;>元素3
    <div id=&#39;b&#39;>元素2</div>
</div>


</html>

More css hover changes the style of child elements and other elements For related articles, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn