简体   繁体   English

Bootstrap 5 单选按钮更改 NET Core 中的背景颜色

[英]Bootstrap 5 Radio Button change Background Color in NET Core

Since moving to Bootstrap 5, I'm no longer able to change the background color with a CSS modification.自从迁移到 Bootstrap 5 后,我不再能够通过 CSS 修改来更改背景颜色。

Any have any ideas to fix this?任何人有任何想法来解决这个问题?

Razor code sample: Razor 代码示例:

<div class="mb-3" style="margin-top: 1.5em">
<div class="d-flex flex-row">
    <div>
        Conditional Logic:
    </div>
    <div class="custom-control custom-radio form-check form-check-inline ms-2">
        <input checked class="custom-control-input form-check-input" type="radio" name="RadioBtn1" id="customRadio1" value="OR">
        <label class="custom-control-label form-check-label" for="customRadio1">OR</label>
    </div>
    <div class="custom-control custom-radio form-check form-check-inline">
        <input class="custom-control-input form-check-input" type="radio" name="RadioBtn2" id="customRadio2" value="AND">
        <label class="custom-control-label form-check-label" for="customRadio2">AND</label>
    </div>
</div>

CSS no longer works: CSS 不再工作:

/* Custom Radio Button color before checked */
.custom-control-label::before {
    background-color: #6C757D;
}

The result I want is to change the white background nearer to the theme's background color:我想要的结果是将白色背景更改为更接近主题的背景颜色:

在此处输入图像描述

Looks like the CSS was slightly wrong, this below seems to work OK:看起来 CSS 有点错误,下面这似乎工作正常:

.custom-control-input {
    background-color: #6C757D;
}

Updated Razor/HMTL:更新的 Razor/HMTL:

<div class="mb-3" style="margin-top: 1.5em">
<div class="d-flex flex-row">
    <div>
        Conditional Logic:
    </div>
    <div class="form-check form-check-inline ms-2">
        <input checked class="custom-control-input form-check-input" type="radio" name="RadioBtn1" id="customRadio1" value="OR">
        <label class="form-check-label" for="customRadio1">OR</label>
    </div>
    <div class="form-check form-check-inline">
        <input class="custom-control-input form-check-input" type="radio" name="RadioBtn1" id="customRadio2" value="AND">
        <label class="form-check-label" for="customRadio1">AND</label>
    </div>
</div>

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM