radio单选框彩色,自定义边框,圆点颜色和大小
本例是《纯css checkbox复选框与radio单选框美化》的扩展,这边就修改了一下css文件,仅仅展示radio单选框
本例主要就是自定义边框的颜色,大小,另外可以每个radio选项单独定义
XML/HTML Code
- <div class="col">
- <h4>Radio(单选按钮)</h4>
- <input class="magic-radio" type="radio" name="radio" id="r1" value="option1">
- <label for="r1" class="radio1">Normal</label>
- <input class="magic-radio" type="radio" name="radio" id="r2" value="option2" checked>
- <label for="r2" class="radio2">Checked</label>
- <input class="magic-radio" type="radio" name="radio" id="r3" value="option3">
- <label for="r3" class="radio3">Normal</label>
- </div>
CSS Code
- .magic-radio {
- position: absolute;
- display: none; }
- .magic-radio + label {
- position: relative;
- padding-left: 30px;
- cursor: pointer;
- vertical-align: middle; }
- .magic-radio + label:hover:before {
- animation-duration: 0.4s;
- animation-fill-mode: both;
- animation-name: hover-color; }
- .magic-radio + label.radio1:before {
- position: absolute;
- top: 0;
- left: 0;
- display: inline-block;
- width: 20px;
- height: 20px;
- content: '';
- border: 2px solid #478846; }
- .magic-radio + label.radio2:before {
- position: absolute;
- top: 0;
- left: 0;
- display: inline-block;
- width: 20px;
- height: 20px;
- content: '';
- border: 2px solid #C30C22; }
- .magic-radio + label.radio3:before {
- position: absolute;
- top: 0;
- left: 0;
- display: inline-block;
- width: 20px;
- height: 20px;
- content: '';
- border: 2px solid #868686; }
- .magic-radio + label:after {
- position: absolute;
- display: none;
- content: ''; }
- .magic-radio[disabled] + label {
- cursor: not-allowed;
- color: #e4e4e4; }
- .magic-radio:checked + label:before {
- animation-name: none; }
- .magic-radio:checked + label:after {
- display: block; }
- .magic-radio + label:before {
- border-radius: 50%; }
- .magic-radio + label.radio1:after {
- top: 6px;
- left: 6px;
- width: 12px;
- height: 12px;
- border-radius: 50%;
- background: #478846; }
- .magic-radio + label.radio2:after {
- top: 6px;
- left: 6px;
- width: 12px;
- height: 12px;
- border-radius: 50%;
- background: #00ff00; }
- .magic-radio + label.radio3:after {
- top: 6px;
- left: 6px;
- width: 12px;
- height: 12px;
- border-radius: 50%;
- background: #868686; }
原文地址:http://www.freejs.net/article_biaodan_642.html