• <legend id='UToYw'><style id='UToYw'><dir id='UToYw'><q id='UToYw'></q></dir></style></legend>
    <i id='UToYw'><tr id='UToYw'><dt id='UToYw'><q id='UToYw'><span id='UToYw'><b id='UToYw'><form id='UToYw'><ins id='UToYw'></ins><ul id='UToYw'></ul><sub id='UToYw'></sub></form><legend id='UToYw'></legend><bdo id='UToYw'><pre id='UToYw'><center id='UToYw'></center></pre></bdo></b><th id='UToYw'></th></span></q></dt></tr></i><div id='UToYw'><tfoot id='UToYw'></tfoot><dl id='UToYw'><fieldset id='UToYw'></fieldset></dl></div>

      1. <small id='UToYw'></small><noframes id='UToYw'>

        <tfoot id='UToYw'></tfoot>
          <bdo id='UToYw'></bdo><ul id='UToYw'></ul>

        如何在html中自定义单选按钮

        How to customize radio button in html(如何在html中自定义单选按钮)

            <tbody id='RU45L'></tbody>

          <i id='RU45L'><tr id='RU45L'><dt id='RU45L'><q id='RU45L'><span id='RU45L'><b id='RU45L'><form id='RU45L'><ins id='RU45L'></ins><ul id='RU45L'></ul><sub id='RU45L'></sub></form><legend id='RU45L'></legend><bdo id='RU45L'><pre id='RU45L'><center id='RU45L'></center></pre></bdo></b><th id='RU45L'></th></span></q></dt></tr></i><div id='RU45L'><tfoot id='RU45L'></tfoot><dl id='RU45L'><fieldset id='RU45L'></fieldset></dl></div>
            <bdo id='RU45L'></bdo><ul id='RU45L'></ul>
            <legend id='RU45L'><style id='RU45L'><dir id='RU45L'><q id='RU45L'></q></dir></style></legend>

            <small id='RU45L'></small><noframes id='RU45L'>

            1. <tfoot id='RU45L'></tfoot>
                • 本文介绍了如何在html中自定义单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试获取这样的单选按钮..

                  I am trying to get radio button like this..

                  但我越来越喜欢了

                  如果没有选择任何选项,我需要自定义单选按钮,它应该在里面显示白色.如果选择单选按钮,它应该在框内显示绿色.如何做到这一点?

                  If No option is selected, I need to customize the radio button and it should show white color inside it. If radio button is selected, it should show green color inside the box. How to achieve this?

                  这是我尝试过的.

                  index.html

                  <!doctype html>
                  <html>
                    <head>
                      <meta charset="utf-8">
                  <style>
                  /* Radio Button CSS*/
                  label {
                      display: inline;
                  }
                  .radio-1 {
                      width: 193px;
                  }
                  .button-holder {
                      float: left;
                      margin-left: 6px;
                      margin-top: 16px;
                  }
                  .regular-radio {
                      display: none;
                  }
                  .regular-radio + label {
                      background-color: #fafafa;
                      border: 2px solid #cacece;
                      border-radius: 50px;
                      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 -15px 10px -12px rgba(0, 0, 0, 0.05) inset;
                      display: inline-block;
                      padding: 11px;
                      position: relative;
                  
                  }
                  .regular-radio:checked + label:after {
                      background: none repeat scroll 0 0 #94E325;
                      border-radius: 50px;
                      box-shadow: 0 0 10px rgba(0, 0, 0, 0.3) inset;
                      content: " ";
                      font-size: 36px;
                      height: 8px;
                      left: 7px;
                      position: absolute;
                      top: 7px;
                      width: 8px;
                  }
                  .regular-radio:checked + label {
                      background-color: #e9ecee;
                      border: 2px solid #adb8c0;
                      color: #99a1a7;
                      padding: 11px;
                  }
                  .regular-radio + label:active, .regular-radio:checked + label:active {
                      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1) inset;
                  }
                  </style>
                    </head>
                    <body>
                   <div class="button-holder">
                  <input type="radio" checked="" class="regular-radio" name="radio-1-set" id="radio-1-set"><label for="radio-1-set"></label><br>
                  <input type="radio" checked="" class="regular-radio" name="radio-1-set" id="radio-2-set"><label for="radio-2-set"></label><br>
                  </div>
                      </body>
                  </html>
                  

                  推荐答案

                  只需添加 :before 伪元素来处理 radio 按钮被选中之前的颜色.您可以将其添加到您的 CSS:

                  Just add the :before pseudo element to take care of the color before the radio button is checked. You could add this to your CSS:

                   .regular-radio + label:before {
                    background: none repeat scroll 0 0 #FDFDFD;
                    border-radius: 50px;
                    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3) inset;
                    content: " ";
                    font-size: 36px;
                    height: 8px;
                    left: 7px;
                    position: absolute;
                    top: 7px;
                    width: 8px;
                  }
                  

                  工作演示.您当然可以更改此标签的 background 以完全匹配您显示的示例.希望对您有所帮助.

                  Working demo. You can ofcourse change the background of this label to match exactly the example you show. Hope it helps.

                  这篇关于如何在html中自定义单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  keeping radio buttons checked after form submit(表单提交后保持选中单选按钮)
                  Styling radio button - not work in IE and Firefox(样式单选按钮 - 在 IE 和 Firefox 中不起作用)
                  Bootstrap radio button quot;checkedquot; flag(Bootstrap 单选按钮“已选中旗帜)
                  Toggle HTML radio button by clicking its label(通过单击标签来切换 HTML 单选按钮)
                  Javascript how to change radio button label text?(Javascript如何更改单选按钮标签文本?)
                  How can I automatically select specific radio buttons with Greasemonkey?(如何使用 Greasemonkey 自动选择特定的单选按钮?)
                    <tfoot id='IfW59'></tfoot>
                      <tbody id='IfW59'></tbody>

                      <bdo id='IfW59'></bdo><ul id='IfW59'></ul>
                      • <i id='IfW59'><tr id='IfW59'><dt id='IfW59'><q id='IfW59'><span id='IfW59'><b id='IfW59'><form id='IfW59'><ins id='IfW59'></ins><ul id='IfW59'></ul><sub id='IfW59'></sub></form><legend id='IfW59'></legend><bdo id='IfW59'><pre id='IfW59'><center id='IfW59'></center></pre></bdo></b><th id='IfW59'></th></span></q></dt></tr></i><div id='IfW59'><tfoot id='IfW59'></tfoot><dl id='IfW59'><fieldset id='IfW59'></fieldset></dl></div>
                      • <small id='IfW59'></small><noframes id='IfW59'>

                        <legend id='IfW59'><style id='IfW59'><dir id='IfW59'><q id='IfW59'></q></dir></style></legend>