跨浏览器自定义复选框 [英] cross browser custom checkbox

查看:75
本文介绍了跨浏览器自定义复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用于创建自定义复选框的 HTML CSS 代码。我相信我的代码具有正确的Web工具包,但在FireFox上似乎不起作用。

I have HTML and CSS code that I've used to build a custom checkbox. I believe my code has the correct web-kits but it doesn't seem to work on FireFox.

这里是代码:

HTML

 <input type='checkbox' style="float: left" class='regular-checkbox big-checkbox'
     checked='checked' id='product-45-45' name='product_id_page-0[45-45]'
     value='45-45' data-first_price="11.99" data-second_price="" data-paysys="" />

CSS

.regular-checkbox {
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #fafafa;
    border: 1px solid #cacece;
    box-shadow: 0 1px 2px rgba(0,0,0,0),inset 0 -15px 10px -12px rgba(0,0,0,0);
    -moz-box-shadow: 0 1px 2px rgba(0,0,0,0),inset 0 -15px 10px -12px rgba(0,0,0,0);
    -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0),inset 0 -15px 10px -12px rgba(0,0,0,0);
    padding: 9px;
    border-radius: 20px;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    display: inline-block;
    position: relative;
}
.regular-checkbox:active,
.regular-checkbox:checked:active {
    box-shadow: 0 1px 2px rgba(0,0,0,0),inset 0 1px 3px rgba(0,0,0,0);
    -moz-box-shadow: 0 1px 2px rgba(0,0,0,0),inset 0 1px 3px rgba(0,0,0,0);
    -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0),inset 0 1px 3px rgba(0,0,0,0);
}
.regular-checkbox:checked {
    background-color: #e9ecee;
    box-shadow: 0 1px 2px rgba(0,0,0,0),inset 0 -15px 10px -12px rgba(0,0,0,0),inset 15px 10px -12px rgba(255,0,0,0);
    -moz-box-shadow: 0 1px 2px rgba(0,0,0,0),inset 0 -15px 10px -12px rgba(0,0,0,0),inset 15px 10px -12px rgba(255,0,0,0);
    -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0),inset 0 -15px 10px -12px rgba(0,0,0,0),inset 15px 10px -12px rgba(255,0,0,0);
}
.regular-checkbox:checked:after {
    content: '\2714';
    font-size: 14px;
    position: absolute;
    top: 0;
    left: 3px;
    color: #19a73e;
}
.big-checkbox {
    padding: 18px;
}
.big-checkbox:checked:after {
    font-size: 37px;
    top: -7px;
    left: 2px;
}

所需结果的屏幕截图(适用于Chrome):

Screen shot of the desired outcome (works in Chrome):

推荐答案

尝试使用这段代码,我不知道解释,但是我为您做了一个版本;)

Try use this code, I don't know explain, but I did one version for you ;)

.regular-checkbox{
		display: inline-block;
		border-radius: 50%;
		width: 38px;
		height: 38px;
		border: 1px solid #ccc;
	}
	.regular-checkbox input{
		opacity: 0;
		position: absolute;
	}
	.regular-checkbox small{
		width: 100%;
		height: 100%;
		float: left;
	}
	.regular-checkbox input:checked ~ small:after{
		content: '\2714';
		height: 38px; 
		width: 38px;
		color: green;
		font-size: 26px;
		text-align: center;
		float: left;
	}

<label class="regular-checkbox">
    <input type="checkbox">
    <small></small>
</label>

这篇关于跨浏览器自定义复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆