は、ここでこの答えは、@クバの回答に似ているバックIE 10
に働く平野JavaScriptでシンプルなソリューション、です。 JSを使用してマウスクリックまたはタブボタンを検出するためにクラスを追加/削除します。
のjavascript:
html.clicking .targetElement:focus {
outline: none;
}
/*
or you can try dealing with all visibly focusable elements from the start. I'm not sure if this is all of them, but it's good starting point.
*/
html.clicking a:focus,
html.clicking button:focus,
html.clicking input:focus,
html.clicking textarea:focus {
outline: none;
}
ブラウザの互換性::
querySelector IE 8+
クリッククラスが
CSSが存在するときに、フォーカス:
var htmlElement = document.querySelector('html');
document.addEventListener('click', function(){
htmlElement.classList.add('clicking');
});
document.addEventListener('keyup', function(e){
if (e.keyCode === 9) {
htmlElement.classList.remove('clicking');
}
});
はその後にアウトラインをオフにします IE 10+
IE10より前のブラウザをサポートする必要がある場合は、jQueryを使用します。
$(document).on('click', function(){
$('html').addClass('clicking');
});
$(document).on('keyup', function(){
if (e.keyCode === 9) {
$('html').removeClass('clicking');
}
});
あなたは彼が –
ああを求めていた溶液に正反対を提供している、彼の質問「誰かがマウスを介して、それをクリックするだけで青のアウトラインを削除するスマートな方法がある」ではないでしょうか? – bens
いいえ、彼の質問は、タブのアウトラインを残しているときに削除するときです。 :activeを使用してアウトラインを削除すると、タブでアクティブなときにも削除されます:p –