element-ui中el-switch相关样式操作,等比例缩小、靠右对齐
等比例缩小
.el-switch {
transform: scale(0.5);
}
靠右对齐
在element-ui中el-tree的树根上有个el-switch开关,我想将开关移动到外层的div最右侧并对齐,我的代码框架大概如下:
<div>
<el-tree>
<span slot-scope="{node,data}">
<span> {{node.label}} </span>
<el-switch></el-switch>
</span>
</el-tree>
<div>
实现方法:
外层div增加style=“position: relative;
”,
el-switch增加:style=“position: absolute; right: 0;
”
<div style="position: relative;">
<el-tree>
<span slot-scope="{node,data}">
<span>{{node.label}}<span>
<el-switch style="position: absolute; right: 0;"> </el-switch>
</span>
</el-tree>
</div>