1.利用radial-gradient实现(vue动态控制background)
<style>
.radio{
display: inline-block;
vertical-align: bottom;
width:20px;
height: 20px;
background:radial-gradient(circle,#fff 20%,#409eff 20%);
border-radius: 50%;
}
</style>
</head>
<body>
<div class="radio"></div>
<span>option1</span>
<div class="radio"></div>
<span>option2</span>
</body>
实现效果:
2. ::after伪元素添加内圆环,vue可动态绑定class改变按钮样式
.radio-item(@click="radioSelect(index,selectItem,questionItem)")
.radio(:class="{radiochecked:(selectItem.isAnswer=='Y')}")
span.radio-content {{selectItem.optionName}}
.radio-item{
cursor: pointer;
.radio {
width: 16px;
height: 16px;
background-color: #fff;
border: 1px #dcdfe6 solid;
border-radius: 50%;
display: inline-block;
vertical-align: bottom;
margin-right: 5px;
position: relative;
}
.radiochecked{
background-color: #409eff;
}
.radio::after{
width: 4px;
height: 4px;
border-radius: 100%;
background-color: #fff;
content: "";
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}
}
实现效果如下: