56

I have a styled down down, but I cannot remove the dotted border when it is clicked in Firefox. I've used outline: none but it still doesn't work. Any ideas?

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>

Please see this jsFiddle.

shrewdbeans
  • 11,971
  • 23
  • 69
  • 115

2 Answers2

152

Found my answer here: https://stackoverflow.com/a/18853002/1261316

It wasn't set as the correct answer, but it worked perfectly for me:

select:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 #000;
}
select {
    background: transparent;
}
mb21
  • 34,845
  • 8
  • 116
  • 142
shrewdbeans
  • 11,971
  • 23
  • 69
  • 115
  • 15
    (!) this also makes the color of the list items transparent – Simon Jan 28 '14 at 11:47
  • 1
    tx, works for me (options are visible in FF 29 OSX) – ptim Jun 04 '14 at 06:22
  • Grate , does what it should do , thanks . FF ubuntu 14 lts – Dragutescu Alexandru Oct 05 '15 at 11:29
  • 2
    If you you are using Bootstrap or have any transitions on your input, don't forget to add ```transition: color 0ms;```, or else you will see the dotted line fade out at the moment you focus on the select box! – Micros Dec 16 '15 at 14:58
  • @Simon: you're right, it does. I found that the best way to avoid that is to use two additional rules: `option { text-shadow: none }` to undo the shadow effect, and `option:not(:checked) { color: #000; }` - *or whatever the normal text color is* - to reset the color. *Not checked*, because the selected option should get its color and background from the user agent stylesheet. – Zilk Jan 14 '16 at 20:48
  • @shrewdbeans Thanks for sharing, it's solve my issue to :) – Tsurule Vol Sep 20 '17 at 14:45
-2

This will help you. Place it on top of your style sheet.

/**
* 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;
}
Migol
  • 8,161
  • 8
  • 47
  • 69