How To Remove Outline Border From Input Button

后端 未结 14 1521
有刺的猬
有刺的猬 2020-12-02 08:43

when click somewhere else the border disappears, tried onfocus none, but didn\'t help, how to make ugly button border disappear when click on?

相关标签:
14条回答
  • 2020-12-02 09:17

    Removing the outline is an accessibility nightmare. People tabbing using keyboards will never know what item they're on.

    Best to leave it, as most clicked buttons will take you somewhere anyway, or if you HAVE to remove the outline then isolate it a specific class name.

    .no-outline {
      outline: none;
    }
    

    Then you can apply that class whenever you need to.

    0 讨论(0)
  • 2020-12-02 09:20

    This one worked for me

    button:focus {
        border: none;
        outline: none;
    }
    
    0 讨论(0)
  • 2020-12-02 09:23

    Focus outlines in Chrome and FF

    enter image description here enter image description here

    removed:

    enter image description here

    input[type="button"]{
       outline:none;
    }
    input[type="button"]::-moz-focus-inner {
       border: 0;
    }
    

    Demo

    Accessibility (A11Y)

    /* Don't forget! User accessibility is important */
    input[type="button"]:focus {
      /* your custom focused styles here */
    }
    
    0 讨论(0)
  • 2020-12-02 09:23

    Set both the outline and the box-shadow properties of the button to none and make them important.

    input[type="button"] {
        outline: none !important;
        box-shadow: none !important;
    } 
    


    The reason for setting the values to important is that, if you are using other CSS libraries or frameworks like Bootstrap, it might get overridden.

    0 讨论(0)
  • 2020-12-02 09:27

    using outline:none; we can remove that border in chrome

    <style>
    input[type="button"]
    {
        width:120px;
        height:60px;
        margin-left:35px;
        display:block;
        background-color:gray;
        color:white;
        border: none;
        outline:none;
    }
    </style>
    
    0 讨论(0)
  • 2020-12-02 09:27

    To avoid the problem caused when you change the outline property on a focus, is tho give a visual effect when the user Tab on the input button or click on it.

    In this case is a submit type, but you can apply to a type="button" too.

    input[type="submit"]:focus {
        outline: none !important;
        background-color: rgb(208, 192, 74);
    }

    0 讨论(0)
提交回复
热议问题