Polymer @import theme file with :host in styles has no affect

后端 未结 2 1498
感情败类
感情败类 2020-12-19 22:46

Back with another Polymer question, I have a Polymer/Electron app that I\'m trying to style.

I want to create a theme.css that contains a :host

2条回答
  •  执念已碎
    2020-12-19 23:17

    There's a new concept called style module (actually a dom-module element behind the scene) introduced in Polymer 1.1 (read it here) and the old way of including external stylesheets has been deprecated (read it here).

    Basically, you need to create an html file like how you normally create an element to store your styles. The id defines the name of this file that will be referenced later on.

    
    
      
    
    

    Then obviously you need to import this file in your page.

    
    

    Now, there are two scenarios.

    1. If you are using custom-style at the document level, you need to include the style module you previously defined like this -

    2. If you simply want to include the style module inside one of your elements, do this -

    Have a look at this plunker that demonstrates both scenarios.

    Keep in mind that in your particular example, since you are using :host, I assume you will go with scenario 2. So this plunker should be a bit more clearer.

提交回复
热议问题