【问题标题】:How can I change the background color of a radio button's "circle" by CSS?如何通过 CSS 更改单选按钮的“圆圈”的背景颜色?
【发布时间】:2022-12-12 13:22:23
【问题描述】:

我正在使用反应开发电子应用程序,我必须按照下面的原型图像实现单选按钮。 如您所见,我想通过 CSS 更改单选按钮“圆圈”的背景颜色(颜色代码为 rgba(255,252,229,1))。我用谷歌搜索了这个,但是,我找不到答案......

类似的问题是在单选按钮中更改边框和“选中”圆圈。

我尝试了以下代码,但背景没有改变...... (注意:我想实现的颜色代码是rgba(255,252,229,1),但不清楚。所以,在这道题中,我想实现的颜色是“绿色”。)

  • background和background-color
.radio-button-input[type=radio]{
    width: 33px;
    height: 33px;

    background-color: green;
}

==> 没有改变。

  • accent-color
.radio-button-input[type=radio]{
    width: 33px;
    height: 33px;

    accent-color: green;
}

===>“选中”圆圈,而不是背景圆圈,已更改

【问题讨论】:

    标签: html css reactjs electron


    【解决方案1】:

    使用 css accent-color

    input {
      accent-color: auto;
      display: block;
      width: 33px;
      height: 33px;
    }
    
    input.custom {
      accent-color: green;
    }
    <label> My Custom radio
    <input type="radio" class="custom" />
    </label>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-25
      • 2011-10-03
      • 2020-08-20
      • 2021-12-14
      • 2014-11-05
      • 1970-01-01
      • 2015-01-03
      • 1970-01-01
      相关资源
      最近更新 更多