<legend id='oILDg'><style id='oILDg'><dir id='oILDg'><q id='oILDg'></q></dir></style></legend>
  • <tfoot id='oILDg'></tfoot>

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

          <bdo id='oILDg'></bdo><ul id='oILDg'></ul>
      2. 使用 CSS 样式单选按钮并使用图像

        时间:2023-10-20
          <bdo id='BrnaX'></bdo><ul id='BrnaX'></ul>

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

              <legend id='BrnaX'><style id='BrnaX'><dir id='BrnaX'><q id='BrnaX'></q></dir></style></legend>
                <tbody id='BrnaX'></tbody>

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

                  本文介绍了使用 CSS 样式单选按钮并使用图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Is there a easy and simple way to style radio buttons with only CSS, so I click an image instead of a bullet? Like thumbs up / thumbs down for example.

                  I have two radio buttons, and I need to register which one is clicked. The radio buttons are getting visible when you press a button, and when you click on a radio button, a text replaces the radio buttons.

                  BUTTON > RADIO BUTTONS > TEXT

                  This is how far I've gotten:

                  HTML

                  <div id="txtradiocall_lille" style="display:none;">
                                <input id="Radio1" type="radio" value="yes" class="input_hidden" /><label for="yes"><img src="http://www.xxxx.dk/images/images/thumb_up_green.png" alt="Yes" /></label>
                                Yes
                                <input id="Radio1" type="radio" value="no" class="input_hidden" /><label for="no"><img src="http://www.xxxx.dk/images/images/thumb_down.png" alt="No" /></label>
                                No
                              </div>
                  

                  CSS

                  .txtradiocall_lille input[type='radio']
                  {
                      display:inline;
                  }
                  
                  .input_hidden {
                      position: absolute;
                      left: -9999px;
                  }
                  
                  .selected {
                      background-color: #ccc;
                  }
                  
                  #txtradiocall_lille label {
                      display: inline-block;
                      cursor: pointer;
                  }
                  
                  #txtradiocall_lille label:hover {
                      background-color: #efefef;
                  }
                  
                  #txtradiocall_lille label img {
                      padding: 3px;
                  
                  }
                  

                  radio click handler

                   $("input[type='radio']").change(function () {
                   var selection = $(this).val();
                    getcallaskok(selection, talok);
                   });
                  

                  At the moment, I'm getting the images instead of the radio bullets, but it seems the clicks are not getting registered, because I don't get the text I need after the click.

                  Can someone help me, please?

                  解决方案

                  Best practice is to simply use the label element like so:

                  <label id="labelone" for="myradiobutton"></label>
                  
                  <input type="radio" value="xxx" id="myradiobutton">
                  

                  Then you use css to style the label. In your case to probably add your image as a background.

                  Then you just hide the actual radio button by moving it off-screen using absolute positioning. N.B. Don't hide the radio button using the display:none or visibility:hidden as this is bad for accessibility.

                  So the user will click the label and the radio button which is now off screen will be selected.

                  这篇关于使用 CSS 样式单选按钮并使用图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在一次计算中求和单选按钮值和复选框值 - javascript 和 html 下一篇:如何使用 Flask 通过 HTML 表单携带带空格的字符串

                  相关文章

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

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

                        <bdo id='EIKKM'></bdo><ul id='EIKKM'></ul>