目录
1、html
- 1、html
- 2、css
- 3、原文参考链接
添加class=“switch”,避免全局样式污染。
<el-switch class="switch" v-model="switchvalue" :validate-event="true" active-text="新增" inactive-text="累计" inactive-color="#409EFF" :width="40" :active-value="1" :inactive-value="0" @change="agent_change" > position: absolute; display: none; color: #fff !important; } /*打开时文字位置设置*/ .switch .el-switch__label--right { z-index: 1; } /* 调整打开时文字的显示位子 */ .switch .el-switch__label--right span { margin-left: 9px; } /*关闭时文字位置设置*/ .switch .el-switch__label--left { z-index: 1; } /* 调整关闭时文字的显示位子 */ .switch .el-switch__label--left span { margin-left: 22px; } /*显示文字*/ .switch .el-switch__label.is-active { display: block; } /* 调整按钮的宽度 */ .switch.el-switch .el-switch__core, .el-switch .el-switch__label { width: 60px !important; margin: 0; }3、原文参考链接
原文链接