将第三方 css 实施到自己的 less 结构中
Implementing third party css into own less structure
如果我想实现第三方 css,这是我从外部源提供到我自己的 less-compile 结构中的。有什么可靠的方法可以解决这个问题。因为我可以预期外部源会不时更新,所以我想尽可能少地更改它,同时以某种方式将它映射到我本地编译的 css。
例如,如果我的样式表将按钮 class 设置为 "k-button",而外部 css 将其设置为 "button",是否有好的命名方式匹配同时仍确保它们完全独立?
您可以使用 extend feature:
以下少代码:
.button {
background-color: yellow;
}
.button-k {
background-color: red;
}
.button:extend(.button-k){}
输出:
.button {
background-color: yellow;
}
.button-k,
.button {
background-color: red;
}
导致 .button
的 background-color
现在将是 red
。
在两个class没有设置相同属性的情况下,您可以尝试重置.button-k
未定义的值:
.button {
border: 1px solid white;
background-color: yellow;
}
.button-k {
border: initial;
background-color: red;
}
.button:extend(.button-k){}
没有 border: initial;
声明 .button
class 仍然会得到原始声明的白色边框。
如果我想实现第三方 css,这是我从外部源提供到我自己的 less-compile 结构中的。有什么可靠的方法可以解决这个问题。因为我可以预期外部源会不时更新,所以我想尽可能少地更改它,同时以某种方式将它映射到我本地编译的 css。
例如,如果我的样式表将按钮 class 设置为 "k-button",而外部 css 将其设置为 "button",是否有好的命名方式匹配同时仍确保它们完全独立?
您可以使用 extend feature:
以下少代码:
.button {
background-color: yellow;
}
.button-k {
background-color: red;
}
.button:extend(.button-k){}
输出:
.button {
background-color: yellow;
}
.button-k,
.button {
background-color: red;
}
导致 .button
的 background-color
现在将是 red
。
在两个class没有设置相同属性的情况下,您可以尝试重置.button-k
未定义的值:
.button {
border: 1px solid white;
background-color: yellow;
}
.button-k {
border: initial;
background-color: red;
}
.button:extend(.button-k){}
没有 border: initial;
声明 .button
class 仍然会得到原始声明的白色边框。