代码之家  ›  专栏  ›  技术社区  ›  NeitoFR

如何在共享样式聚合元素中修改CSS变量

  •  0
  • NeitoFR  · 技术社区  · 7 年前

    下面是我想要常规更改的CSS变量的名称:

    <dom module id=“共享样式”> :根{ --asc:4caf50;/*应用辅助颜色*/ </style> </dom module>
    
    
    
    
    所以……它似乎不具有一般性的变化。我需要找到另一种方法来做到这一点。
    
    

    <link rel="import" href="../bower_components/polymer/polymer-element.html">
    
    <!-- shared styles for all views -->
    <dom-module id="shared-styles">
      <template>
        <style>
          :root {
            --apc: #099b34;
            --asc: #4CAF50; /*App Secondary Color*/
          }
        </style>
      </template>
    </dom-module>

    晚上愉快,谢谢

    编辑1:我尝试了@d.mares给出的第一个方法,但它不起作用。 As you can see

    编辑2: error css

    2 回复  |  直到 7 年前
        1
  •  0
  •   Diego P    7 年前

    this.updateStyles 传递新值:

      this.updateStyles({
        '--apc': 'blue',
        '--as': 'red'
      });
    
        2
  •  0
  •   Gabriele Petrioli    7 年前

    来自 docs