Remove blue border from css custom-styled button in Chrome

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

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

22条回答
  •  借酒劲吻你
    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.

提交回复
热议问题