1. 程式人生 > >03.CSS選擇器-->交集並集選擇器

03.CSS選擇器-->交集並集選擇器

img ont meta tex es2017 nta color 學習 mage

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>高級選擇器</title>
    <style>
        /*交集選擇器*/
        /*既是P標簽,類名稱又會text的元素字體變為紅色*/
        p.text{
            color: red;
        }
        /*並集選擇器*/
        /*讓container下的所有元素內容為藍色*/
        #container p,span,em,strong{
            color: blue;
        }
    </style>
</head>
<body>
    <!--交集選擇器-多個選擇器包含的元素-->
    <p>好好學習1</p>
    <p class="text">好好學習2</p>
    <p class="text">好好學習3</p>
    <p>好好學習4</p>

    <!--並集選擇器-多個選擇所有匹配的元素-->
    <div id="container">
        <p>好好學習1</p>
        <span>好好學習2</span><br>
        <em>好好學習3</em><br>
        <strong>好好學習4</strong>
    </div>

</body>
</html>

技術分享

03.CSS選擇器-->交集並集選擇器