H5 18-序选择器

18-序选择器

 

我是段落1

我是段落2

我是段落2

我是标题

DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>18-序选择器title>
    <style>
        /*
        p:first-child{
            color: red;
        }
        */
        /*
        p:first-of-type{
            color: blue;
        }
        */
        /*
        p:last-child{
            color: red;
        }
        */
        /*
        p:last-of-type{
            color: blue;
        }
        */
        /*
        p:nth-child(3){
            color: red;
        }
        */
        /*
        p:nth-of-type(3){
            color: blue;
        }
        */
        /*
        p:nth-last-child(2){
            color: red;
        }
        */
        /*
        p:nth-last-of-type(2){
            color: red;
        }
        */
        /*
        p:only-child{
            color: purple;
        }
        */
        /*
        p:only-of-type {
            color: red;
        }
        */
        .para:only-of-type {
            color: red;
        }
    style>
head>
<body>


<p class="para">我是段落1p>
<div>
    <p class="para">我是段落2p>
    <p class="para">我是段落2p>
    <h1>我是标题h1>
div>
body>
html>

 

转载于:https://www.cnblogs.com/ljcgood66/p/6440386.html

你可能感兴趣的:(H5 18-序选择器)