zoukankan      html  css  js  c++  java
  • 前端 CSS的选择器 属性选择器

    属性选择器,字面意思就是根据标签中的属性,选中当前的标签。

    属性选择器 通常在表单控件中 使用比较多

    根据属性查找

    /*用于选取带有指定属性的元素。*/
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="x-ua-compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Title</title>
        <style type="text/css">
            label[for]{
                color: red;
            }
        </style>
    
    </head>
    <body>
        <div>
            <form>
                <div>
                    <label for="user">用户名</label>
                    <input type="text" id="user">
                </div>
    
            </form>
        </div>
    </body>
    </html>

    根据属性和值查找

    /*用于选取带有指定属性和值的元素。*/
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="x-ua-compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Title</title>
        <style type="text/css">
            label[for="user"]{
                color: red;
            }
        </style>
    
    </head>
    <body>
        <div>
            <form>
                <div>
                    <label for="user">用户名</label>
                    <input type="text" id="user">
                </div>
    
            </form>
        </div>
    </body>
    </html>

    表单常用

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="x-ua-compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Title</title>
        <style type="text/css">
            input[type="text"]{
                color: red;
            }
        </style>
    
    </head>
    <body>
        <div>
            <form>
                <div>
                    <label for="user">用户名</label>
                    <input type="text" id="user">
                </div>
    
            </form>
        </div>
    </body>
    </html>

  • 相关阅读:
    数据库的读读事务也会产生死锁
    数据库中的two phase locking
    排序合并连接(sort merge join)的原理
    SQL Server2016 原生支持JSON
    公司内部培训SQL Server传统索引结构PPT分享
    postgresql的ALTER经常使用操作
    POJ 1458 Common Subsequence(最长公共子序列LCS)
    Docker 1.3 公布
    spring bean之间的关系:继承;依赖
    hdu 1215 七夕节
  • 原文地址:https://www.cnblogs.com/mingerlcm/p/10800358.html
Copyright © 2011-2022 走看看