我正在使用polygit加载聚合物组件。有什么办法可以覆盖--primary-color而又没有任何CSS hacks?
这是我加载聚合物的方式。
<base href="http://polygit.org/polymer+v1.4/components/">
<link href="polymer/polymer.html" rel="import">
<link rel="import" href="paper-button/paper-button.html">
<link rel="import" href="paper-input/paper-input.html">
<link rel="import" href="paper-input/paper-textarea.html">
在您的自定义元素中使用它
:host{
--primary-color:blue;
}
或者,如果您使用HTML进行处理,则使用custom-style
并更新其中的值:root
以将其应用于任何地方,或者使用内部值将其应用于特定元素
将其应用于所有元素
<style is="custom-style">
:root{
--primary-color:blue;
}
将其应用于单个元素
<style is="custom-style">
paper-card{
--primary-color:blue;
}
或者,如果您正在设计应用程序,我建议创建app-theme.html
一个将作为您应用程序主题的中央存储库,并导入app-theme
usinglink
标签。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句