CSS选择符-----元素选择符

时间:2018-12-10 13:14:45   收藏:0   阅读:152

   通配选择符(*)

          选定所有对象

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            *{
                color: #FF0000;
                font-weight: bold;
            }
        </style>
    </head>
    <body>
        <div>
            <p>第一个段落。</p>
            <p>第二个段落。</p>
            <ul>
                <li>Java</li>
                <li>C#</li>
            </ul>
        </div>
    </body>
</html>

   类型选择符(Element)

          以文档语言对象类型作为选择符

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            p{
                color: #FF0000;
                font-weight: bold;
            }
        </style>
    </head>
    <body>
        <div>
            <p>第一个段落。</p>
            <p>第二个段落。</p>
            <ul>
                <li>Java</li>
                <li>C#</li>
            </ul>
        </div>
    </body>
</html>

   ID选择符(Element#ID)

          以唯一标识符id属性等于myid的E对象作为选择符

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            #language{
                color: #FF0000;
                font-weight: bold;
            }
        </style>
    </head>
    <body>
        <div>
            <p>第一个段落。</p>
            <p>第二个段落。</p>
            <ul id="language">
                <li>Java</li>
                <li>C#</li>
            </ul>
        </div>
    </body>
</html>

   类选择符(Element.class)

          以class属性包含myclass的E对象作为选择符

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            .a{
                color: #0000FF;
            }
            .b{
                font-weight:bold;
                font-size: x-large;
            }
        </style>
    </head>
    <body>
        <div>
            <p>第一个段落。</p>
            <p>第二个段落。</p>
            <ul class="a b">
                <li>Java</li>
                <li>C#</li>
            </ul>
        </div>
    </body>
</html>

 

原文:https://www.cnblogs.com/fengfuwanliu/p/10095510.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!