CSSを使用してテキスト入力/テキスト領域をクリックしたときに、デフォルトの青と黄色の輝きを削除することは可能ですか?
CSSを使用してテキスト入力/テキスト領域をクリックしたときに、デフォルトの青と黄色の輝きを削除することは可能ですか?
回答:
textarea, select, input, button { outline: none; }ただし、グロー/アウトラインを維持することは、ユーザーが現在どの要素に焦点を合わせているかを確認するのに役立つため、アクセシビリティにとって実際に有益であると主張されています。
疑似要素 ':focus'を使用して、ユーザーが入力を選択したときにのみ入力をターゲットにすることもできます。
この効果は、非入力要素でも発生する可能性があります。より一般的な解決策として次の作品を見つけました
:focus {
  outline-color: transparent;
  outline-style: none;
}更新::focusセレクターを使用する必要がない場合があります。たとえば、要素があり、<div id="mydiv">stuff</div>このdiv要素に外側の輝きがあった場合は、通常のように適用します。
#mydiv {
  outline-color: transparent;
  outline-style: none;
}<button>エレメントの場合に機能しますが、ほとんどの場合、クリックオンしているため、グローオンフォーカスのメリットは特にありません。
                    45.0.2454.101 m
                    :focusセレクタのために、私はちょうど置くoutline-colorとoutline-style私のdivのCSSに。
                    Webkitベースのブラウザーでのテキストエリアのサイズ変更:
textareaにmax-heightとmax-widthを設定しても、視覚的なサイズ変更ハンドルは削除されません。試してください:
resize: none;(はい、私は「ユーザーの期待に反することは何もしないようにしてください」に同意しますが、場合によっては、つまり、Webアプリケーションのコンテキストでは意味があります)
Webkitフォーム要素の外観を最初からカスタマイズするには:
-webkit-appearance: none;none、both、horizontal、vertical、とinherit。
                    Bootstrapのボタンからグローを削除したい場合(私の考えでは必ずしも悪いUXではありません)、次のコードが必要になります。
.btn:focus, .btn:active:focus, .btn.active:focus{
  outline-color: transparent;
  outline-style: none;
}.btn:active:focus実際にボタンを押しながらグローを削除する必要がありました。
                    ボタンが外線を削除するために使用されることもあります。
input:hover
input:active, 
input:focus, 
textarea:active,
textarea:hover,
textarea:focus, 
button:focus,
button:active,
button:hover
{
    outline:0px !important;
}<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>