效果:
element 样式修改覆盖:
<el-checkbox class="base-checkbox" v-model="checked">排污企业(30)</el-checkbox>
.base-checkbox .el-checkbox__label {
padding-left: 6px;
font-size: 12px;
color: rgba(255, 255, 255, 0.6);
}
.base-checkbox .el-checkbox__inner {
border: 1px solid rgba(103, 229, 255, 0.6);
border-radius: 1px;
background-color: initial;
width: 12px;
height: 12px;
}
.base-checkbox .el-checkbox__input.is-checked .el-checkbox__inner,
.el-checkbox__input.is-indeterminate .el-checkbox__inner {
border-color: rgba(103, 229, 255, 1);
background-color: initial;
}
.base-checkbox .el-checkbox__input.is-focus .el-checkbox__inner {
border-color: rgba(103, 229, 255, 0.6);
}
.base-checkbox .el-checkbox__input.is-checked + .el-checkbox__label {
color: rgba(103, 229, 255, 1);
}
.base-checkbox .el-checkbox__input.is-checked .el-checkbox__inner::after {
-webkit-transform: rotate(90deg) scaleY(1);
transform: rotate(90deg) scaleY(1);
}
.base-checkbox .el-checkbox__inner::after {
-webkit-box-sizing: content-box;
box-sizing: content-box;
content: '';
border: none;
position: absolute;
left: 1px;
top: 1px;
width: 8px;
height: 8px;
background: rgba(103, 229, 255, 1);
-webkit-transform: rotate(90deg) scaleY(0);
transform: rotate(90deg) scaleY(0);
// -webkit-transition: -webkit-transform 0.15s ease-in 0.05s;
// transition: -webkit-transform 0.15s ease-in 0.05s;
// transition: transform 0.15s ease-in 0.05s;
// transition: transform 0.15s ease-in 0.05s, -webkit-transform 0.15s ease-in 0.05s;
// transition: transform 0.15s ease-in 0.05s, -webkit-transform 0.15s ease-in 0.05s;
-webkit-transition: unset;
transition: unset;
}
原生样式:
<template>
<div class="radio">
<input type="checkbox" id="sex1" />
<label for="sex1"></label>
<span class="text">男</span>
</div>
</template>
<script>
export default {}
</script>
<style lang="scss" scoped>
.radio {
position: relative;
display: inline-block;
margin-right: 12px;
cursor: pointer;
}
.radio input {
width: 12px;
height: 12px;
appearance: none; /*清楚默认样式*/
-webkit-appearance: none;
opacity: 0;
outline: none;
z-index: 8; /*让input层级高于label,使之能选中*/
cursor: pointer;
}
.radio label {
position: absolute;
left: 0;
top: 6px;
width: 12px;
height: 12px;
border: 1px solid rgba(103, 229, 255, 0.6);
border-radius: 1px;
margin-top: -2px;
}
.radio input:checked + label::after {
content: '';
position: absolute;
left: 1px;
top: 1px;
width: 8px;
height: 8px;
background: rgba(103, 229, 255, 1);
transition: transform 0.15s ease-in 0.05s, -webkit-transform 0.15s ease-in 0.05s;
transform-origin: center;
}
.radio .text {
font-size: rgba(255, 255, 255, 0.6);
}
</style>