web前端作业

作业要求:

<!-- 用外部样式 -->

<!-- 选取主标题(<h1>)将颜色改成粉色。

    选取所有列表项(<li>)。

        选取第一个列表项。背景颜色改为红

        选取最后一个列表项。背景颜色改为绿

        选取容器内带有"class"为"text"的段落。

        选取容器内的第一个盒子。

        选取所有带有"class"为"text"的元素(无论其在容器内还是容器外)。 -->

01.代码

<!DOCTYPE html>
<html>
    <style>
        h1{
            color: pink;
        }
    </style>
    <style>
        li{
 
        }
    </style>
    <style>
        li:first-child{
            background-color: red ;
        }
    </style>
    <style>
        li:last-child{
            background-color: green;
        }
    </style>
    <style>
        .container.text{
 
        }
    </style>
    <style>
        .container div.box:first-child{
 
        }
    </style>
    <style>
        .text{
 
        }
    </style>
<head>
    <title>CSS选择器练习题</title>
 
</head>
<body>
    <div class="container">
        <h1>主标题</h1>
        <ul class="list">
            <li>项目1</li>
            <li>项目2</li>
            <li>项目3</li>
        </ul>
        <p class="text">这是一个段落。</p>
        <div class="box">盒子1</div>
        <div class="box">盒子2</div>
    </div>
    <p class="text">另一个在容器外的段落。</p>
</body>
 
</html>

运行结果:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值