【问题标题】:How to group selector in CSS for two different input types [duplicate]如何在CSS中为两种不同的输入类型分组选择器[重复]
【发布时间】:2017-04-06 19:06:29
【问题描述】:

在这里,我有两种不同的<input> 类型,“文本”和“密码”,我对它们都有相同的样式。 如何分组?

input[type=text] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    color : green;
}

input[type=password] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    color : green;
}

【问题讨论】:

    标签: html css


    【解决方案1】:
    input[type=text], input[type=password] {
        width: 100%;
        padding: 12px;
        border: 1px solid #ccc;
        color : green;
    }
    

    更多信息:http://www.htmldog.com/guides/css/intermediate/grouping/

    【讨论】:

    【解决方案2】:

    有几种方法可以做到这一点。一种简单的解决方案是在两个 Input 标签上放置一个 CSS 类,如下所示。

    <input type="text" class="formatter" />
    <input type="password" class="formatter" />
    

    然后将该类的样式设置如下。

    input.formatter {
        width: 100%;
        padding: 12px;
        border: 1px solid #ccc;
        color : green;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-24
      • 2016-06-09
      • 2013-08-07
      • 2017-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多