How to remove the border highlight on an input text element

前端 未结 18 1217
庸人自扰
庸人自扰 2020-11-22 05:49

When an HTML element is \'focused\' (currently selected/tabbed into), many browsers (at least Safari and Chrome) will put a blue border around it.

For the layout I a

18条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 06:51

    None of the solutions worked for me in Firefox.

    The following solution changes the border style on focus for Firefox and sets the outline to none for other browsers.

    I've effectively made the focus border go from a 3px blue glow to a border style that matches the text area border. Here's some border styles:

    Dashed border (border 2px dashed red):

    No border! (border 0px):

    Textarea border (border 1px solid gray):

    Here is the code:

    input:focus, textarea:focus {
        outline: none; /** For Safari, etc **/
        border:1px solid gray; /** For Firefox **/
    }
    
    #textarea  {
      position:absolute;
      top:10px;
      left:10px;
      right:10px;
      width:calc(100% - 20px);
      height:160px;
      display:inline-block;
      margin-top:-0.2em;
    }

提交回复
热议问题