单选框,复选框美化(纯css)

时间:2019-02-18
本文章向大家介绍单选框,复选框美化(纯css),主要包括单选框,复选框美化(纯css)使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

单选框,复选框美化

废话不多说先上图
接着是代码

index.html

 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no" name="viewport" />

<style type="text/css">
body {
	font: 14px/150% microsoft yahei,tahoma;
	}
.clear {
	clear: both
	}
.RadioStyle input {
	display: none
	}
.RadioStyle label {
	border: 1px solid #00a4ff;
	padding: 2px 10px 2px 5px;
	line-height: 28px;
	min-width: 80px;
	text-align: center;
	float: left;
	margin: 2px;
	border-radius: 4px
	}
.RadioStyle input:checked + label {
	background: url(images/ico_checkon.svg) no-repeat right bottom;
	background-size: 21px 21px;
	color: #00a4ff
	}
</style>

<title>纯CSS 单/复选框 美化</title>
</head>
<body>

单选框

<div class="RadioStyle">
    <div class="Block PaddingL">
        <input type="radio" name="Storage" id="model1" />
        <label for="model1">单选框A</label>
        <input type="radio" name="Storage" id="model2" />
        <label for="model2">单选框B</label>
        <input type="radio" name="Storage" id="model3" />
        <label for="model3">单选框C</label>
        <input type="radio" name="Storage" id="model4" checked />
        <label for="model4">单选框D</label>
    </div>
</div>

<div class="clear"></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
多选框

<div class="RadioStyle">
    <div class="Block PaddingL">
        <input type="checkbox" id="love1" />
        <label for="love1">多选框1</label>
        <input type="checkbox" id="love2" />
        <label for="love2">多选框2</label>
        <input type="checkbox" id="love3" />
        <label for="love3">多选框3</label>
        <input type="checkbox" id="love4" checked />
        <label for="love4">多选框4</label>
    </div>
</div>

<div class="clear"></div>
</body>
</html>
svg图
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<svg version="1.1" id="ico_checkon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
	 y="0px" viewBox="0 0 42 42" style="enable-background:new 0 0 42 42;" xml:space="preserve">
<style type="text/css">
	.st0{fill-rule:evenodd;clip-rule:evenodd;fill:#00A4FF;}
	.st1{fill:#FFFFFF;}
</style>
<g>
	<g>
		<polygon class="st0" points="42,42 42,0.5 0.5,42 		"/>
	</g>
</g>
<path class="st1" d="M19.4,26.9l8.5,8.5L25,38.2l-8.5-8.5L19.4,26.9z M36.4,21.2l2.8,2.8L25.1,38.2l-2.8-2.8L36.4,21.2z"/>
</svg>