您好,欢迎访问成都祈钰瑶科技有限公司!

全国咨询热线

18982081108

成都网站建设公司,成都网站UI设计,成都网站安全维护,成都网站内容优化服务

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

本文小编为大家详细介绍“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单选和多选按钮怎么给图片加样式”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注创新互联行业资讯频道。