批改状态:合格
                        老师批语:
                    
                            <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>css中常用的选这器</title>
    <style>
        /*标签选这器:根据标签名来选择元素*/
        ul{
            margin: 0;
            width: 550px;
            border: 1px darkcyan;
            padding: 10px 5px;
        }
        /*子块撑开父级区块*/
        ul:after{
            content: '';
            display: block;
            clear: both;
        }
        ul li{
            list-style: none;
            float: left;
            width: 40px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            border-radius:50%;
            box-shadow: 2px 2px 2px #888;
            background: skyblue;
            margin: 5px;
        }
        /*id选这器*/
        #item1{
            background: #ccc;
        }
        /*类选择器calls选这器*/
        .item2{
            background: center;
        }
        /*属性选择器:属性值*/
        ul li[class="item2"]{
            background: green;
        }
        /*属性选择器:属性值中包含指定的子串*/
        ul[class*="t"]{
            background-color: green;
        }
        /*后代选择器、曾级选择器*/
        body ul li{
            border:1px solid black;
        }
        /*子选择器*/
        ul > li[class$="pig"]{
            background-color: greenyellow;
        }
        /*相邻选择器*/
        ul li[class$="pig"] ~ * {
            background-color: aquamarine;
            color: white;
        }
        /*相邻兄弟选择器*/
        ul li[class$="pig"] + li {
            background-color: pink;
            color: black;
        }
        /*群组选择器*/
        h1,p {
            font-size: 2rem;
            font-weight: lighter;
            margin: 0;
        }
        /*伪类选择器:链接*/
        a{
            font-size: 2rem;
        }
        /*访问前*/
        a:link{
            color: tomato;
        }
        /*访问后*/
        a:visited{
            color: violet;
        }
        /*获取焦点的时候*/
        a:focus{
            color: aqua;
        }
        /*鼠标悬停的时候*/
        a:active{
            color: blue;
        }
        /*伪类选择器*/
        ul li:first-child{
            background-color: cadetblue !important;
        }
        ul il:last-child{
            background-color: red;
        }
        ul li:last-child{
            background-color: red;
        }
        ul il:nth-child(5){
            background-color: red;
        }
        ul li:nth-child(odd) {
            /*偶数: even,奇数 odd*/
            background-color: purple!important;
        }
        /*伪类选择器: 根据子元素的数量*/
        ol :only-child {
            background-color: lawngreen;
        }
        ol li:only-child {
            background-color: lawngreen;
        }
        ul li:nth-last-child(3) {
            background-color: wheat;
        }
        ol li:nth-of-type(2) {
            background-color: wheat;
        }
        :empty {
            width: 220px;
            height: 270px;
            background-color: coral;
        }
        :empty:after {
            content: '看到我了吗?亲';
        }
        :empty:before {
            /*通过伪类添加的元素,默认都是行内元素,不支持宽高设置,可以通过设置背景图片的方式来间接处理*/
            content: url("../0814/images/dog.jpg");
        }
    </style>
</head>
<body>
<ul>
    <li id="item1">1</li>
    <li class="item2">2</li>
    <li class="cat dog pig ">3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
    <li>8</li>
    <li>9</li>
    <li>10</li>
</ul>
<h1>css选这器深夜练习大法</h1>
<p>css学习非常重要,对以后的js.jqurey以及其他前端</p>
<a href="http://php.cn">php中文网</a>
<ol>
    <li>列表项1</li>
</ol>
<ol>
    <li>列表项1</li>
    <li>列表项2</li>
    <li>列表项3</li>
</ol>
<ol>
    <li>列表项1</li>
    <li>列表项2</li>
    <li>列表项3</li>
    <li>列表项4</li>
</ol>
</body>
</html>点击 "运行实例" 按钮查看在线实例
手写代码:

                Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号