zoukankan      html  css  js  c++  java
  • 0056 CSS3属性选择器

    1. 什么是 CSS3

      • CSS2 的基础上拓展、新增的样式
    2. CSS3 发展现状

      • 移动端支持优于 PC
      • CSS3 目前还草案,在不断改进中
      • CSS3 相对 H5,应用非常广泛
    3. 属性选择器列表

    在这里插入图片描述

    4.属性选择器代码演示

    button {
      cursor: pointer;
    }
    button[disabled] {
      cursor: default
    }
    
    input[type=search] {
      color: skyblue;
    }
    
    span[class^=black] {
      color: lightgreen;
    }
    
    span[class$=black] {
      color: lightsalmon;
    }
    
    span[class*=black] {
      color: lightseagreen;
    }
    
    demo
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            /* 属性选择器使用方法 */
            /* 选择的是:  既是button 又有 disabled 这个属性的元素 */
            /* 属性选择器的权重是 10 */
            /* 1.直接写属性 */
            
            button[disabled] {
                cursor: default;
            }
            
            button {
                cursor: pointer;
            }
            /* 2. 属性等于值 */
            
            input[type="search"] {
                color: blue;
            }
            /* 3. 以某个值开头的 属性值 */
            
            div[class^="icon"] {
                color: red;
            }
            /* 4. 以某个值结尾的 */
            
            div[class$="icon"] {
                color: green;
            }
            /* 5. 可以在任意位置的 */
            
            div[class*="icon"] {
                color: red;
            }
        </style>
    </head>
    
    <body>
        <!-- disabled 是禁用我们的按钮 【1、input也可以使用disabled。    2、disabled是属性,不是样式,不能写在style中。】 -->
        <button>按钮</button>
        <button>按钮</button>
        <button disabled="disabled">按钮</button>
        <button disabled="disabled">按钮</button>
        <br>
        <input type="text" name="" id="" value="文本框">
        <input type="text" name="" id="" value="文本框">
        <input type="text" name="" id="" value="文本框">
        <br>
        <input type="search" name="" id="" value="搜索框">
        <input type="search" name="" id="" value="搜索框">
        <input type="search" name="" id="" value="搜索框">
        <br>
        <div class="icon1">图标1</div>
        <div class="icon2">图标2</div>
        <div class="icon3">图标3</div>
        <div class="iicon3">图标4</div>
        <div class="absicon">图标5</div>
    </body>
    
    </html>
    

    在这里插入图片描述

    补充:input表单不可用 --- disabled="disabled"
    <form action="/example/html/form_action.asp" method="get">
      <p>First name: <input type="text" name="fname" /></p>
      <p>Last name: <input type="text" name="lname" disabled="disabled" /></p>
      <input type="submit" value="Submit" />
    </form>
    
  • 相关阅读:
    HDOJ 1677 Nested Dolls(LIS+Dilworth)
    POJ 1548 Robots (Dilworth)
    POJ 1065 Wooden Sticks
    第三百四十天 how can I 坚持
    第三百三十九天 how can I 坚持
    第三百三十八天 how can I 坚持
    第三百三十七天 how can I 坚持
    第三百三十六天 how can I 坚持
    第三百三十五天 how can I 坚持
    第三百三十四天 how can I 坚持
  • 原文地址:https://www.cnblogs.com/jianjie/p/12127112.html
Copyright © 2011-2022 走看看