zoukankan      html  css  js  c++  java
  • 7CSS选择器210909

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    
        <style>
    
            /*1 元素选择器*/
           p{
               text-align: center;
               color: red;
           }
    
            /*2 id选择器*/
            #paral1{
                text-align: center;
                color: yellow;
            }
    
            /*3 类选择器(适用于所有元素)*/
            .center{
                text-align: center;
                color: blue;
            }
    
            /*4 类选择器(仅适用于<p>元素)*/
            p.center1{
                text-align: center;
                color: green;
            }
    
            /*5 引用两个类的HTML元素*/
            p.center2{
                text-align: center;
                color: orange;
              }
            p.large{
                font-size: 300%;
            }
    
            /*6 通用选择器*/
            /**{*/
            /*    text-align: center;*/
            /*    color: black;*/
            /*  }*/
    
    
            /*7 分组选择器*/
            h1, h2, p{
                text-align: center;
                color: pink;
                font-size: 300%;
              }
        </style>
    
    </head>
    <body>
    
        1 元素选择器
        p{
        text-align: center;
        color: red;
        }
        <p>every paragraph will be affected by the style</p>
        <p id="paral"> Me too!</p>
        <p>And me!</p>
    
    
        2 id选择器
        #paral1{
        text-align: center;
        color: darkred;
        }
        <p id="paral1"> Hello World! </p>
    
        3 类选择器(适用于所有元素)
        .center{
        text-align: center;
        color: blue;
        }
        <h1 class="center">绿且居中 标题 </h1>
        <p class="center">绿且居中 段落 </p>
    
        4 类选择器(仅适用于<'p'>元素)
        p.center1{
        text-align: center;
        color: green;
        }
        <h1 class="center1">标题 不受影响</h1>
        <p class="center1">段落 居中变蓝</p>
    
    
        5 引用两个类的HTML元素
        p.center2{
        text-align: center;
        color: orange;
        }
        p.large{
        font-size: 300%;
        }
        <h1 class="center2">标题不受影响</h1>
        <p class="center2">段落居中变橙色</p>
        <p class="center2 large">段落居中变橙色且字体变大</p>
    
        6 通用选择器 //通用注释了,要不都染了
        *{
        text-align: center;
        color: black;
        }
        <h1> Hello world! how are you ??? </h1>
        <p> 每个月元素都被染了把 </p>
        <p> 学之染人,甚于丹青 </p>
    
        7 分组选择器
        h1, h2, p{
        text-align: center;
        color: pink;
        font-size: 300%;
        }
        <h1> 还好吗? </h1>
        <h2></h2>
        <p> 那就好 </p>
    
        权重优先等级:important>内联选择器(style) > id选择器 >类选择器 > 标签选择器 >通配符选择器
        值为:
        style       1000
        id            100
        class       10
        标签        1
        通配符     0
    </body>
    <script src="./scripts/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
    
    </script>
    </html>
  • 相关阅读:
    web.xml配置文件详解
    spring MVC配置文件详解
    路由导航刷新后导致当前选中的导航样式不见的解决办法
    vue input 使用v-model想要改变父属性的写法
    JS 编写一个指定范围内的随机数返回方法
    vue-router 3.1.5报错:vue-router.esm.js?8c4f:2089 Uncaught (in promise)
    Failed to mount component: template or render function not defined. vue
    vscode 操作debugger for chrome的配置文件写法
    JS操作DOM方法总结
    npm 代理配置的方法
  • 原文地址:https://www.cnblogs.com/Doner/p/15258151.html
Copyright © 2011-2022 走看看