简体   繁体   English

单选按钮CSS3-自定义

[英]Radio Button CSS3 - Customization

I am trying to customize Radio buttons on bootstrap but it is not working, When i try outside bootstrap environment in plain HTML it works, Below is code for HTML followed by CSS I am using 我正在尝试在引导程序上自定义单选按钮,但是它不起作用,当我在纯HTML中尝试在外部引导程序环境中工作时,以下是我正在使用的HTML代码以及CSS

<div class="radio">
        <label>
          <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
          My Current AMP Policies
        </label>
      </div>
      <div class="radio">
        <label>
          <input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
          Financial Planning and Retirement Advice
        </label>
      </div>
      <div class="radio">
        <label>
          <input type="radio" name="optionsRadios" id="optionsRadios3" value="option3">
           LifeCover
        </label>
      </div>

THE CSS CSS

.newradio input[type=radio] {display: none;}
.newradio label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 13px;
}
.newradio label:before {
content: "";
display: inline-block;
width: 14px;
height: 14px;
border-radius: 7px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 3px;
background-color: #fff;
border:solid 1px #bcb882;
}
.newradio input[type=radio]:checked + .newradio label:before {
content: "";
background: url(../../Content/images/radio-check.png);
display: inline-block;
}

The reason for .newradio is I am using that div as parent class of above given HTML, I am getting proper display of my Radios but Checked status (the image radio-check) is not showing, I tried using color change instead of background image but that doesn't work either. .newradio的原因是我正在使用该div作为以上给定HTML的父类,我正在正确显示我的Radios,但是未显示Checked状态(图像Radio-check),我尝试使用颜色更改而不是背景图像但这也不起作用。

Does anyone has experience in customizing radio button in bootstrap? 有没有人有在引导程序中自定义单选按钮的经验? please guide 请指导

Manoj Soni 玛诺·索尼(Manoj Soni)

You need to find the bootstrap css class and overwrite it. 您需要找到bootstrap css类并将其覆盖。 Or use ID instead of class in the css. 或者使用ID代替CSS中的类。 When that also don't work try !important. 如果那也不起作用,请尝试!important。

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

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