Angular2 dynamic change CSS property

前端 未结 5 1368
粉色の甜心
粉色の甜心 2020-12-01 02:07

We are making an Angular2 application and we want to be able to somehow create a global CSS variable (and update the properties\' values whenever changed wh

5条回答
  •  情话喂你
    2020-12-01 02:34

    1) Using inline styles

    2) Use multiple CSS classes mapping to what you want and switch classes like:

     /* CSS */
     .theme { /* any shared styles */ }
     .theme.blue { color: blue; }
     .theme.red { color: red; }
    
     /* Template */
     

    Code samples from: https://angular.io/cheatsheet

    More info on ngClass directive : https://angular.io/docs/ts/latest/api/common/index/NgClass-directive.html

提交回复
热议问题