CSS 样式深度选择

77 阅读1分钟

1. /deep/

使用场景:修改ui库组件样式

/deep/ .el-input.is-disabled .el-input__inner {
  background-color: #fff;
}

2. !important

使用场景:css 样式继承或嵌套

.el-input.is-disabled .el-input__inner {
  background-color: #fff !important;
}

3. 解决 sass 预编下 深度样式选择 /deep/ 编译失败问题

::v-deep 代替 /deep/ 对元素进行深度样式选择

/deep/ .el-input.is-disabled .el-input__inner {
  background-color: #fff;
}

// 代替

::v-deep .el-input.is-disabled .el-input__inner {
  background-color: #fff;
}