1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php 多选按钮 单选和多选按钮如何给图片加样式

php 多选按钮 单选和多选按钮如何给图片加样式

时间:2022-04-21 05:39:40

相关推荐

php 多选按钮 单选和多选按钮如何给图片加样式

这次给大家带来单选和多选按钮如何给图片加样式,单选和多选按钮给图片加样式的注意事项有哪些,下面就是实战案例,一起来看一下。

之前一直看到有人在问,单选按钮和多选按钮怎么加样式、怎么把按钮变大?下面把我做的一个例子分享出来

代码如下:

$(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");

});

});

/* 多选/单选 */

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: 1px solid #049CDB;

}

.label_check input, .label_radio input {

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: 0 0px

}

.lblby label.c_on {

background-position: 0 -26px;

}

.lblby .label_radio {

background-position: 0 -52px;

}

.lblby label.r_on {

background-position: 0 -78px;

}

.lblby .label_check input, .lblby .label_radio input {

position: absolute;

left: -9999px;

}

Checkbox1

Checkbox2

Radio1

Radio2

Radio3

相信看了这些案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!

相关阅读:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。