无法从Firefox选择下拉列表中删除轮廓/虚线边框

时间:2013-10-18 13:40:56

标签: html css forms

我有一个样式向下,但在 Firefox 中单击时,我无法删除虚线边框。我使用过outline: none但它仍然不起作用。有什么想法吗?

CSS:

.styled-select {
    background: lightblue;
    font-size: 20px;
    height: 50px;
    line-height: 50px;
    position: relative;
    border: 0 none !important;
    outline: 1px none !important;
}
.styled-select select {
   background: transparent;
   border: 0;
   border-radius: 0;
   height: 50px;
   line-height: 50px;
   padding-top: 0; padding-bottom: 0;
   width: 100%;
   -webkit-appearance: none;       
   text-indent: 0.01px;
   text-overflow: '';
   border: 0 none !important;
   outline: 1px none !important;
}

HTML:

<div class="styled-select">
    <select id="select">
        <option value="0">Option one</option>
        <option value="1">Another option</option>
        <option value="2">Select this</option>
        <option value="3">Something good</option>
        <option value="4">Something bad</option>
    </select>
</div>

请参阅此jsFiddle

2 个答案:

答案 0 :(得分:134)

在这里找到我的答案:https://stackoverflow.com/a/18853002/1261316

它没有被设置为正确的答案,但它对我来说非常有用:

select:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 #000;
}
option:not(:checked) {
  color: black; /* prevent <option>s from becoming transparent as well */
}

答案 1 :(得分:-1)

这会对你有所帮助。将它放在样式表的顶部。

/**
* Address `outline` inconsistency between Chrome and other browsers.
*/

a:focus {
    outline:0;
}

/**
 * Improve readability when focused and also mouse hovered in all browsers.
 */

a:active,
a:hover {
    outline: 0;
}