Pierre D
Pierre D

Reputation: 76

Select options are transparent on Mozilla Firefox

I use a lang switcher with land flag as select background that change when the lang change.

Everything works as expected but on Mozilla Firefox the options are transparent, except on hover. I cannot find anything to fix it.

I've made a stackblitz so You can better see the problem: (The images are not the good ones, that why it render "ugly") https://stackblitz.com/edit/angular-u5jgzt

Thanks for help me / sharing me link that can help me.

app.component.ts import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  /**
   * define the current language in the app
   *
   * @type {('français' | 'english')}
   * @memberof LangSwitcherComponent
   */
  currentLang: 'français' | 'english' = 'français';

  /**
   * Change the translation language
   *
   * @param {*} event
   * @memberof LangSwitcherComponent
   * @returns {void}
   */
  changeLang(): void {
    this.currentLang = this.currentLang === 'français' ? 'english' : 'français';
  }
}

app.component.css

select {
  -webkit-appearance: none;
  -moz-appearance: none;
  height: 21px;
  width: 21px;
  border-radius: 100%;
  background: url('https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Flag_of_France_%281794%E2%80%931815%2C_1830%E2%80%931958%29.svg/250px-Flag_of_France_%281794%E2%80%931815%2C_1830%E2%80%931958%29.svg.png');
  background-size: cover;
  border: 1px solid #fff;
  color: transparent;
  cursor: pointer;
}
select.en {
  background: url('https://upload.wikimedia.org/wikipedia/commons/f/f2/Flag_of_Great_Britain_%281707%E2%80%931800%29.svg');
  background-size: cover;
}
select option {
  background-color: white;
  padding: 10px;
}
p {
  font-size: 15px;
  line-height: 19px;
  margin: auto;
  margin-top: 1px;
}

Upvotes: 1

Views: 466

Answers (2)

Cornel Raiu
Cornel Raiu

Reputation: 3005

Just update the select option style to:

select option {
  background-color: white;
  padding: 10px;
  color: #000;
}

You are setting color: transparent in the select{ } style and that one cascades down to the option.

Upvotes: 1

Sonia
Sonia

Reputation: 1919

You need too specify color CSS in the options

select option {

    color: black;

}

Upvotes: 2

Related Questions