CSS 组合选择器

CSS 组合选择器

:使用逗号分隔,同时应用。

 

多个id选择器拼接到一起

含有:i1 i2 i3的标签同时应用css样式。 

<html>
<head>
    <!-- style 设置头部标签 -->
    <style>
       /*可将多个id选择器名称拼接到一组*/
        #i1,#i2,#i3{
            /* 改变背景颜色 */
            background-color: #2459a2;
            /* 改变字体颜色 */
            color: white;
        }
    </style>
</head>
<body>
    <div id="i1">1</div>
    <div id="i2">2</div>
    <div id="i3">3</div>
</body>
</html>

 

多个class选择器拼接到一起

含有:i1 i2 i3的标签同时应用css样式。 

<html>
<head>
    <!-- style 设置头部标签 -->
    <style>
        /*可将多个class类选择器名称拼接到一组*/
        .i1,.i2,.i3{
            background-color: #2459a2;
            color: white;
        }
    </style>
</head>
<body>
    <div class="i1">1</div>
    <div class="i2">2</div>
    <div class="i3">3</div>
</body>
</html>

 

posted @ 2019-02-21 14:39  kevin.Xiang  阅读(1587)  评论(0编辑  收藏  举报