【问题标题】:How to put color border in my inputs in html如何在我的 html 输入中添加颜色边框
【发布时间】:2014-04-24 11:00:45
【问题描述】:

大家好,如果我点击它们,有人知道如何在任何输入框或选择框中输入边框颜色吗?和图片一样。

【问题讨论】:

    标签: html css


    【解决方案1】:

    您需要:focus 选择器:

    HTML:

    <label for="my-text">My Label</label>
    <input type="text" name="my-text" id="my-text" />
    

    CSS

    input[type=text]:focus { outline:1px solid red; }
    

    input[type=text]:focus {
        -webkit-box-shadow: 1px 1px 3px 1px #FF0000;
        box-shadow: 1px 1px 3px 1px #FF0000;
    }
    

    【讨论】:

    • outline != border.
    【解决方案2】:

    使用类似的东西

    input[type=text]:focus { border-color: #f00; }
    

    在您的 CSS 中。对您来说重要的部分是 :focus,但我在此处包含 [text],因此您不会看到看起来很有趣的复选框等。

    【讨论】:

    猜你喜欢
    • 2021-05-13
    • 1970-01-01
    • 2019-06-10
    • 2010-10-09
    • 2020-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-11
    相关资源
    最近更新 更多