html标签 伪类作用,html – :checked伪类在Chrome中不起作用

我正在使用此css创建自定义复选框:

input[type="checkbox"] {

background: transparent;

border: inherit;

width: auto;

}

input[type=checkbox] {

display: none;

}

input[type=checkbox] + input + label,

input[type=checkbox] + label,

div:not(#foo) > input[type=checkbox] + label,

div:not(#foo) > input[type=checkbox] + input + label {

cursor: pointer;

height: 16px;

padding: 0 0 0 18px;

background: transparent url(/assets/images/checkbox-unchecked.png) no-repeat left 3px;

}

input[type=checkbox]:checked + input + label,

input[type=checkbox]:checked + label,

div:not(#foo) > input[type=checkbox]:checked + label,

div:not(#foo) > input[type=checkbox]:checked + input + label {

background: transparent url(/assets/images/checkbox-checked.png) no-repeat left 3px;

}

.ie6 input[type=checkbox],

.ie7 input[type=checkbox],

.ie8 input[type=checkbox] {

display: inline-block;

*display: inline;

*zoom: 1;

}

这是我的HTML标记:

Keep me!

输入元素由Razor中的@ Html.EditorFor(model => model.BooleanProp)创建.此代码在Chrome中运行正常.实际上在Chrome中,当我们点击复选框时,我们会在点击提交bottun后看到效果(实际上我的意思是更改标签的背景图像,显示复选框是否已选中).有什么好主意吗?

UPDATE

这是一个demo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值