温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CSS中怎么实现平级与儿子级样式

发布时间:2021-07-26 14:07:03 来源:亿速云 阅读:108 作者:Leah 栏目:web开发

这篇文章给大家介绍CSS中怎么实现平级与儿子级样式,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

input:checked+ol:这个是讲当inoput 拥有了checked后它平级的OL拥有的样式。
input:checked+ol>li:中的大于是指当inoput 拥有了checked后它平级的OL下面儿子辈的li的样式,孙子辈的不继承。

Html代码 

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<title>用户界面(UI)元素状态伪类选择符 E:checked_CSS参考手册_web前端开发参考手册系列</title>  
<style type="text/css">
input[type=radio]:checked + span{background:blue;}
input[type=radio]:checked + span:after{content:" 我被选中了";}
input[type=checkbox]:checked + span{background:#f00;}
input[type=checkbox]:checked + span:before{content:" 我被选中了";}
div.classFather > div.classSon div.classSon{
background-color: lightgray;
line-height: 40px;
}
div.classFather > div.classSon > div.classSonS > div.classSonC {
background-color: lightgray;
line-height: 40px;
}
</style>
</head>
<body>
<form method="post" action="#">
<fieldset>
<legend>选中下面的项试试</legend>
<ul>
<li><label><input type="radio" name="colour-group" value="0" /><span>蓝色</span></label></li>
<li><label><input type="radio" name="colour-group" value="1" /><span>红色</span></label></li>
<li><label><input type="radio" name="colour-group" value="2" /><span>黑色</span></label></li>
</ul>
</fieldset>
<fieldset>
<legend>选中下面的项试试</legend>
<ul>
<li><label><input type="checkbox" name="colour-group2" value="0" /><span>蓝色</span></label></li>
<li><label><input type="checkbox" name="colour-group2" value="1" /><span>红色</span></label></li>
<li><label><input type="checkbox" name="colour-group2" value="2" /><span>黑色</span></label></li>
</ul>
</fieldset>
<fieldset>
<legend>子节点样式</legend>
<div class="classFather">
<div class="classSon">孩子
<div class="classSon">孙子
<div class="classSon">重孙子</div>
</div>
</div>

<div class="classSon">孩子
<div class="classSonS">孙子
<div class="classSonC">重孙子</div>
</div>
</div>
</div>
</fieldset>
</form>
</body>
</html>

关于CSS中怎么实现平级与儿子级样式就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

css
AI