前端如何切换主题
1、在皮肤最顶层 做一个classname来标示如 dark light.
.dark button { color: white; background: dark;}.light button { color: dark; background: gray;}

2、这种方式的好处在于, 不用加载额外css, 只需要改变顶层的classname就可以达到切换皮肤的效果

3、通过动态修改 link
<link href="theme.default.css" /><link href="theme.dark.css" id="J-theme-link" />

4、theme.light.css
button { color: white; background: dark;}

5、theme.dark.css
button { color: dark; background: gray;}

6、js控制
function changeTheme(type) { var el = doucment.querySelector('J-theme-link'); el.href = themeUrl + '/theme.' + type + '.css';}

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:128
阅读量:30
阅读量:145
阅读量:95
阅读量:161