Remove blue border from css custom-styled button in Chrome

前端 未结 22 948
闹比i
闹比i 2020-11-22 17:10

I\'m working on a web page, and I want custom-styled

相关标签:
22条回答
  • 2020-11-22 17:21

    try this code for all element which have blue border problem

    *{
    outline: none;
    }
    

    or

    *{
    outline-style: none;
    }
    
    0 讨论(0)
  • 2020-11-22 17:21

    Simply write outline:none;. No need to use pseudo element focus

    0 讨论(0)
  • 2020-11-22 17:22

    Removing outline is terrible for accessibility! Ideally, the focus ring shows up only when the user intends to use the keyboard.

    Use :focus-visible. It's currently a W3C proposal for styling keyboard-only focus using CSS, and is supported in Firefox (caniuse). Until other major browsers support it, you can use this robust polyfill.

    /* Remove outline for non-keyboard :focus */
    *:focus:not(.focus-visible) {
      outline: none;
    }
    
    /* Optional: Customize .focus-visible */
    .focus-visible {
      outline-color: lightgreen;
    }
    

    I also wrote a more detailed post just in case you need more info.

    0 讨论(0)
  • 2020-11-22 17:23

    In my instance of this problem I had to specify box-shadow: none

    button:focus {
      outline:none;
      box-shadow: none;
    }
    
    0 讨论(0)
  • 2020-11-22 17:23

    The fix for Chrome and other browsers

    button:focus { outline: none !important; box-shadow: none !important; }
    
    0 讨论(0)
  • 2020-11-22 17:23

    I had the same problem with bootstrap. I solved with both outline and box-shadow

    .btn:focus, .btn.focus {
        outline: none !important;
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0) !important; // or none
    }
    
    0 讨论(0)
提交回复
热议问题