AngularJS switch css theme on user selection

后端 未结 4 1583
情话喂你
情话喂你 2020-12-19 15:29

I downloaded the themes from bootswatch and I\'m trying to allow the user to switch the theme. When the theme is switched all the bootstap css temporarily goes away until th

4条回答
  •  被撕碎了的回忆
    2020-12-19 15:59

    I think it is not a problem of AngularJS. I think your approach should be different.

    As I know, theme functionality is usually implemented like below.

    1. Create a single CSS file for each theme (cerulean, cosmo, yeti). You should edit CSS files not to conflict each other. (put .cerulean, .cosmo, .yeti in front of all CSS selectors. If you use sass or less, it will be much easier.)

    2. Load all CSS files from the HTML head.

      
      
      
      
    3. If a user select a theme, change a class of body or root element to a corresponding theme name.

      
      
      
      

提交回复
热议问题