Remove Safari/Chrome textinput/textarea glow

后端 未结 13 842

I am wondering if its possible to remove the default blue and yellow glow when I click on a text input / text area using CSS?

相关标签:
13条回答
  • 2020-11-28 18:02

    This effect can occur on non-input elements, too. I've found the following works as a more general solution

    :focus {
      outline-color: transparent;
      outline-style: none;
    }
    

    Update: You may not have to use the :focus selector. If you have an element, say <div id="mydiv">stuff</div>, and you were getting the outer glow on this div element, just apply like normal:

    #mydiv {
      outline-color: transparent;
      outline-style: none;
    }
    
    0 讨论(0)
  • 2020-11-28 18:02

    On textarea resizing in webkit based browsers:

    Setting max-height and max-width on the textarea will not remove the visual resize handle. Try:

    resize: none;
    

    (and yes I agree with "try to avoid doing anything which breaks the user's expectation", but sometimes it does make sense, i.e. in the context of a web application)

    To customize the look and feel of webkit form elements from scratch:

    -webkit-appearance: none;
    
    0 讨论(0)
  • 2020-11-28 18:02

    Sure! You can remove blue border also from all HTML elements using *

    *{
        outline-color: transparent;
        outline-style: none;
      }
    

    And

     *{
         outline: none;   
       }
    
    0 讨论(0)
  • 2020-11-28 18:03
    <select class="custom-select">
            <option>option1</option>
            <option>option2</option>
            <option>option3</option>
            <option>option4</option>
    </select>
    
    <style>
    .custom-select {
            display: inline-block;
            border: 2px solid #bbb;
            padding: 4px 3px 3px 5px;
            margin: 0;
            font: inherit;
            outline:none; /* remove focus ring from Webkit */
            line-height: 1.2;
            background: #f8f8f8;
    
            -webkit-appearance:none; /* remove the strong OSX influence from Webkit */
    
            -webkit-border-radius: 6px;
            -moz-border-radius: 6px;
            border-radius: 6px;
        }
        /* for Webkit's CSS-only solution */
        @media screen and (-webkit-min-device-pixel-ratio:0) { 
            .custom-select {
                padding-right:30px;    
            }
        }
    
        /* Since we removed the default focus styles, we have to add our own */
        .custom-select:focus {
            -webkit-box-shadow: 0 0 3px 1px #c00;
            -moz-box-shadow: 0 0 3px 1px #c00;
            box-shadow: 0 0 3px 1px #c00;
        }
    
        /* Select arrow styling */
        .custom-select:after {
            content: "▼";
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            font-size: 60%;
            line-height: 30px;
            padding: 0 7px;
            background: #bbb;
            color: white;
    
            pointer-events:none;
    
            -webkit-border-radius: 0 6px 6px 0;
            -moz-border-radius: 0 6px 6px 0;
            border-radius: 0 6px 6px 0;
        }
    </style>
    
    0 讨论(0)
  • 2020-11-28 18:07

    I just needed to remove this effect from my text input fields, and I couldn't get the other techniques to work quite right, but this is what works for me;

    input[type="text"], input[type="text"]:focus{
                outline: 0;
                border:none;
                box-shadow:none;
    
        }
    

    Tested in Firefox and in Chrome.

    0 讨论(0)
  • 2020-11-28 18:10

    I experienced this on a div that had a click event and after 20 some searches I found this snippet that saved my day.

    -webkit-tap-highlight-color: rgba(0,0,0,0);
    

    This disables the default button highlighting in webkit mobile browsers

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