純css美化checkbox和radio及選中效果

	<div class="checkbox">
		<input type="checkbox">
		<label for="">全選</label>
	</div>

	<div class="radio">
		<div class="female">
			<input type="radio" id="female" name="sex" value="1" />
			<label for="female">女</label>
		</div>
		<div class="male">                
			<input type="radio" id="male" name="sex" value="2" />
			<label for="male">男</label>
		</div>
	</div>
		input[type="checkbox"],
		input[type="radio"] {
			width: 20px;
			height: 20px;
			background-color:#fff;
			-webkit-appearance:none;
			border:1px solid #c9c9c9;
			border-radius: 2px;
			outline: none;
		}
		input[type="radio"] {border-radius: 50%;}
		input[type="checkbox"]:checked,
		input[type="radio"]:checked {
			background-color: #ff7800;
			border-color: #ff7800;
			background-clip: content-box;
			padding:2px;
		}
			$("input[type='checkbox']").click(function(){
				var check = $(this).attr("checked");
				if(check){	
					$(this).removeAttr("checked");
				}else{	
					$(this).attr("checked","checked");
				}
			})

效果如下:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章