CSS 删除聚焦下拉菜单的虚线边框/轮廓

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9119629/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:48:18  来源:igfitidea点击:

Remove dotted border/outline of focused dropdown menu

css

提问by MacMac

How do you remove the dotted border/outline that is shown when selecting an item from a dropdown menu?

如何删除从下拉菜单中选择项目时显示的虚线边框/轮廓?

enter image description here

在此处输入图片说明

You can see there is a dotted border/outline shown, I want to remove this (screenshot taken in Firefox).

您可以看到显示了一个虚线边框/轮廓,我想删除它(在 Firefox 中截取的屏幕截图)。

Trying the solution below did not remove it:

尝试下面的解决方案并没有删除它:

select:focus, option:focus, select::-moz-focus-inner, option::-moz-focus-inner {
    outline: none;
    border: none;
}

The HTML is just simply this:

HTML只是这样:

<select name="order">
   <option value="desc">Newest to oldest</option>
   <option value="asc">Oldest to newest</option>
</select>

采纳答案by Jawad

On windows 7 and IE9 no border/outline is shown, Instead a blue background is shown. The blue background and in your case the border/outline is managed by the OS. I suspect your are on a Mac?

在 Windows 7 和 IE9 上不显示边框/轮廓,而是显示蓝色背景。蓝色背景和您的情况下的边框/轮廓由操作系统管理。我怀疑你在 Mac 上?

Remove outline from select box in FF

从 FF 中的选择框中删除轮廓

How to remove Firefox's dotted outline on BUTTONS as well as links?

如何删除 Firefox 在按钮和链接上的虚线轮廓?

回答by collect

Add the following to your stylesheet. -

将以下内容添加到您的样式表中。——

select:-moz-focusring { color: transparent;
                        text-shadow: 0 0 0 #000; }

Has always worked for me, hope it helps!

一直为我工作,希望它有帮助!