css in js的一些疑问

1.通过设置颜色 让其网站上显示不同的背景色【就是一个账号设置了一些样式 使其在另一个地方展示所设置的内容】 问题就是这样样式如何设置 让其在修改的时候简单一些
2.我在网上看了下css in js是一个不错的方法 但是我看都是基于框架的例如react 我的网站层内容需要兼容到较低的版本

阅读 1.3k
1 个回答

using dynamic sub class in the html and js code, give you an example in angular.js:

in html:

<div ng-class = getDivClass(userSetting)></div>

in Controller:


$scope.getDivClass = function(userSetting){
     if(userSetting){
        return "blue";
     }
}

in css :

.blue{
   background-color: blue;
}

The above method is implemented by angular.js. if you want to use jquery or something else, the mechanism is similar.

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题