-webkit-appearance: none; 用于消失原生 改变按钮和其他控件的外观,使其类似于原生控件。
-webkit-transform: rotate(45deg); transform: rotate(45deg); 旋转45度
:before 必须有这一项,否则不显示
圆形:
- position: relative;
- width: 21px;
- height: 21px;
- border-width: 1px;
- border-style: solid;
- border-radius: 50%;
- border-color: #c8c7cc;
- background-color: #fff;
对号:
- position: absolute;
- top: 4px;
- left: 7px;
- width: 5px;
- height: 12px;
- border-width: 2px;
- border-top-width: 0;
- border-left-width: 0;
- border-style: solid;
- border-color: #488aff;
- -webkit-transform: rotate(45deg);
- transform: rotate(45deg);
选中:
- border-color: #488aff;
- background-color: #488aff;
- position: relative;
- width: 21px;
- height: 21px;
- border-width: 1px;
- border-style: solid;
- border-radius: 50%;
- border-color: #c8c7cc;
- background-color: #fff;
- position: absolute;
- top: 4px;
- left: 7px;
- width: 4px;
- height: 9px;
- border-width: 1px;
- border-top-width: 0;
- border-left-width: 0;
- border-style: solid;
- border-color: #fff;
- -webkit-transform: rotate(45deg);
- transform: rotate(45deg);
以上是纯传统方式不借助框架字体,但是不能自动跟随点击动作
以下是利用before 及 自带字体 content: "\f1f6"; 以ionic2 为例
<ion-item class="radio1">
<ion-label fixed>简洁单选</ion-label>
<ion-note item-end>
<input name="radio1" type="radio" checked/><span >男</span>
<input name="radio1" type="radio" /><span class="gril">女</span>
</ion-note>
</ion-item>
.radio1 .input-wrapper{
flex: 0 0 118px;
}
.radio1 input{
font-family: "Ionicons";
-webkit-appearance: none;
font-size: 24px;
margin-right: 5px;
vertical-align: middle;
}
.radio1 input[type=radio]:checked:before {
content: "\f149";
color: #488aff;
}
.radio1 input[type=radio]:before {
content: "\f1f6";
}
.radio1 span{
margin-right: 45px;
}