温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

HTML单选和多选按钮怎么给图片加样式

发布时间:2022-03-22 14:02:58 来源:亿速云 阅读:352 作者:iii 栏目:web开发

本文小编为大家详细介绍“HTML单选和多选按钮怎么给图片加样式”,内容详细,步骤清晰,细节处理妥当,希望这篇“HTML单选和多选按钮怎么给图片加样式”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

  代码如下:

  <!DOCTYPEHTML>

  <html>

  <head>

  <metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>

  <scripttype="text/javascript"src="jquery-1.10.2.min.js"></script>

  <scripttype="text/javascript">

  $(function(){

  $("input[type='checkbox']").click(function(){

  if($(this).is(':checked')){

  $(this).attr("checked","checked");

  $(this).parent().removeClass("c_off").addClass("c_on");

  }else{

  $(this).removeAttr("checked");

  $(this).parent().removeClass("c_on").addClass("c_off");

  }

  });

  $("input[type='radio']").click(function(){

  $("input[type='radio']").removeAttr("checked");

  $(this).attr("checked","checked");

  $(this).parent().removeClass("r_off").addClass("r_on").siblings().removeClass("r_on").addClass("r_off");

  });

  });

  </script>

  </head>

  <style>

  /*多选/单选*/

  label{

  display:block;

  cursor:pointer;

  line-height:26px;

  margin-bottom:20px;

  width:26px;

  height:26px;

  line-height:26px;

  float:left;

  margin-top:6px;

  }

  .radios{

  padding-top:18px;

  border-top:1pxsolid#049CDB;

  }

  .label_checkinput,.label_radioinput{

  margin-right:5px;

  }

  .lblby.label_check,.lblby.label_radio{

  margin-right:8px;

  }

  .lblby.label_radio,.lblby.label_check{

  background:url(../images/jxc_btn.png)no-repeat;

  }

  .lblby.label_check{

  background-position:00px

  }

  .lblbylabel.c_on{

  background-position:0-26px;

  }

  .lblby.label_radio{

  background-position:0-52px;

  }

  .lblbylabel.r_on{

  background-position:0-78px;

  }

  .lblby.label_checkinput,.lblby.label_radioinput{

  position:absolute;

  left:-9999px;

  }

  </style>

  <bodyclass="lblby">

  <labelfor="checkbox-01"class="label_checkc_on">

  <inputtype="checkbox"checked="checked"value="1"id="checkbox-01"name="sample-checkbox-01"/>

  Checkbox1</label>

  <labelfor="checkbox-02"class="label_check">

  <inputtype="checkbox"value="1"id="checkbox-02"name="sample-checkbox-02"/>

  Checkbox2</label>

  <labelfor="radio-01"class="label_radior_on">

  <inputtype="radio"value="1"checked="checked"id="radio-01"name="sample-radio"/>

  Radio1</label>

  <labelfor="radio-02"class="label_radior_off">

  <inputtype="radio"value="1"id="radio-02"name="sample-radio"/>

  Radio2</label>

  <labelfor="radio-03"class="label_radior_off">

  <inputtype="radio"value="1"id="radio-03"name="sample-radio"/>

  Radio3</label>

  </body>

  </html>

HTML单选和多选按钮怎么给图片加样式

读到这里,这篇“HTML单选和多选按钮怎么给图片加样式”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI