鍍金池/ 問(wèn)答/HTML5  HTML/ css in js的一些疑問(wèn)

css in js的一些疑問(wèn)

1.通過(guò)設(shè)置顏色 讓其網(wǎng)站上顯示不同的背景色【就是一個(gè)賬號(hào)設(shè)置了一些樣式 使其在另一個(gè)地方展示所設(shè)置的內(nèi)容】 問(wèn)題就是這樣樣式如何設(shè)置 讓其在修改的時(shí)候簡(jiǎn)單一些
2.我在網(wǎng)上看了下css in js是一個(gè)不錯(cuò)的方法 但是我看都是基于框架的例如react 我的網(wǎng)站層內(nèi)容需要兼容到較低的版本

回答
編輯回答
壞脾滊

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.

2017年5月2日 03:10