2

I have been trying to change the default background white color of the option inside the select property, but with no success. I tried to put to my select property an rgba color but it just won't accept it together with my background image(dropdown arrow) so i wrapped it with a div and gave it my background rgba color as you can see here:

<div class="language-dropdown">
    <label>
        <select class="language-select">
            <option class="language-option" selected>English</option>
            <option class="language-option">Italian</option>
            <option class="language-option">Russian</option>
        </select>
    </label>
</div>

When I try to give background rgba to .language-option it just won't change anything, but, if I give it a regular color, for exmaple background:red;, it works.

.language-dropdown {
    background: rgba(255, 255, 255, 0.4);
    display: inline-block;
}
.language-select {
    background: url("http://s10.postimg.org/otetjsoat/language_Arrow.png") no-repeat right;
    background-size: auto 42%;
    width: 88px;
    background-position-x: 73px;
    -webkit-appearance: none;
    -moz-appearance: none;
    color: #fff;
    border: none;
    text-indent: 0.01px;

    padding-left: 5px;
}
.language-option {
    background-color: rgba(255, 255, 255, 0.4);
    /*WONT WORK!!! , but "background-color:red;"  will*/
}

Note: Works on Firefox, while not on Chrome!

You can find my whole fiddle here

Roni Litman
  • 923
  • 1
  • 8
  • 20

3 Answers3

2

it works fine with pink color, for example, you just have to set a non-white transparency color.

.language-option {
    background-color: rgba(212, 31, 31, 0.48);
}
Dmitry Sadakov
  • 2,128
  • 3
  • 19
  • 34
2

Because 255, 255, 255 - it's white:) Of course you can't see anything! Here is answer

.language-dropdown {
    background: rgba(255, 255, 255, 0.4);
    display: inline-block;
}

.language-select {
    background: url("http://s10.postimg.org/otetjsoat/language_Arrow.png") no-repeat right;
    background-size: auto 42%;
    width: 88px;
    background-position-x: 73px;
    -webkit-appearance: none;
    -moz-appearance: none;
    color: #fff;
    border: none;
    text-indent: 0.01px;
    padding-left: 5px;
}

.language-option {
    background-color: rgba(0, 0, 0, 0.4);
}
<div class="language-dropdown">
    <label>
        <select class="language-select">
            <option class="language-option" selected>English</option>
            <option class="language-option">Italian</option>
            <option class="language-option">Russian</option>
        </select>
    </label>
</div>
AleshaOleg
  • 2,171
  • 1
  • 15
  • 29
2
.language-option {
    background-color: rgba(255, 0, 0, 0.4);
}

This code works. It's red with a 40% opacity.

You'r rgba color rgba(255, 255, 255, 0.4) is white... You won't see any difference because the background is also white.

Here you can experiment with RGBa and instantly see what it does: http://www.webopacity.net/RGBA.html

Starfish
  • 3,344
  • 1
  • 19
  • 47