first-child,first-of-type,nth-child(),nth-of-type

first-child,first-of-type,nth-child(),nth-of-type

http://img1.sycdn.imooc.com//climg/5d37030d0001103f17190802.jpg

老师为啥第二个标签好像跟消失了一样,是因为<span>嵌套的原因吗?麻烦老师了

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕码 2019-07-24 09:43:58

同学你好!

用户“gao031”的回答很对,因为第一个p标签没有正确的关闭:

http://img1.sycdn.imooc.com//climg/5d37b7bb0001d0e403930082.jpg

如果帮助到了你 欢迎采纳 祝学习愉快~

提问者 键盘上的莫扎特 2019-07-23 20:54:43
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>选择器测试</title>
    <style type="text/css">
        div p:first-child{
            background: red;
        }
        div p:last-of-type{
            background: orange;
        }   
        div p:nth-child(2){
            background: yellow;
        }
        div p:nth-of-type(4){
            background:blue;
        }
    </style>
</head>
<body>
    <div>
        <p>课程推荐<p>
        <p><span>职业路径</span>&nbsp;HTML5与CSS3实现动态网页</p>
        <p><span>职业路径</span>&nbsp;零基础入门Android语法与界面</p>
        <p><span>职业路径</span>&nbsp;ios基础语法与常用控件</p>
        <p><span>职业路径</span>&nbsp;PHP入门开发</p>
        <p><span>职业路径</span>&nbsp;JAVA入门开发</p>
    </div>
</body>
</html>


  • gao031 #1
    你课程推荐的的后面p标签/的问题
    2019-07-23 22:44:53
  • 提问者 键盘上的莫扎特 回复 gao031 #2
    哈哈哈 瞎了 瞎了
    2019-07-24 10:12:40
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师