好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

jss

jss 介绍

jsS 是一种比 css 更强大的抽象,它使用 JavaScript 以声明和可维护的方式描述样式。它是 一个 高 性能 的 js to css 编译器,可在运行时和服务器端运行。它是低级别并且与框架无关的,大约有 6KB 大小,并且可以通过 插件 API 进行扩展。?

使用场景

构建 JavaScript 很重的应用

使用基于组件的架构

构建可重用的 UI 库

需要 一个 无冲突的 css?(外部 内容 、第三方 UI 组件等)

需要在 js 和 css 之间共享 代码

下载量小很重要

健壮性和 代码 重用很重要

易于维护很重要

Demo

import jss from 'jss'

import preset from 'jss-preset-default'

import color from 'color'

// One time setup with default plugins and settings.

jss.setup(preset())

const styles = {

button: {

fontSize: 12,

'&:hover': {

background: 'blue'

}

},

ctaButton: {

extend: 'button',

'&:hover': {

background: color('blue')

.darken(0.3)

.hex()

}

},

'@media (min-width: 1024px)': {

button: {

width: 200

}

}

}

const {classes} = jss.createStyleSheet(styles).attach()

document.body.innerhtml = `

<button class="${classes.button}">Button</button>

<button>CTA Button</button>

`

生成 结果

<head>

<style>

.button-123456 {

font-size: 12px;

}

.button-123456:hover {

background: blue;

}

.ctaButton-789012 {

font-size: 12px;

}

.ctaButton-789012:hover {

background: red;

}

@media (min-width: 1024px) {

.button-123456 {

min-width: 200px;

}

}

</style>

</head>

<body>

<button class="button-123456">Button</button>

<button class="ctaButton-789012">CTA Button</button>

</body>

网站地址 : https://cssinjs.org

GitHub: https://github.com/cssinjs/jss

网站描述: 一个 高 性能 的 JS to CSS 编译器

jss官方网站

官方网站: https://cssinjs.org

如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。

查看更多关于jss的详细内容...

  阅读:34次

上一篇

下一篇

第1节:curl.js    第2节:jade    第3节:jspm-cli    第4节:angular-cli    第5节:lerna    第6节:duo.js    第7节:swc    第8节:WebJars    第9节:fetch    第10节:babel-plugin-preval    第11节:browserify    第12节:Lebab    第13节:bundle-buddy    第14节:esprima    第15节:FIS3    第16节:prerender-loader    第17节:Parcel    第18节:lit-html    第19节:Neutrino    第20节:walle    第21节:webpack    第22节:pug    第23节:bower    第24节:Snowpack    第25节:template.js    第26节:Forge    第27节:stylis.js    第28节:Liquid    第29节:npx    第30节:jss    第31节:component    第32节:faster.js    第33节:Juicer    第34节:Jiko    第35节:laytpl    第36节:CoffeeScript    第37节:ghcjs    第38节:critters    第39节:vue-loader    第40节:swig    第41节:Workerize    第42节:Bit    第43节:Acorn    第44节:hyperHTML    第45节:ESL    第46节:script.js    第47节:yarn    第48节:MobX    第49节:Vulcan    第50节:vue-cli    第51节:WeFlow    第52节:qiankun乾坤    第53节:elf    第54节:create-react-app    第55节:CNPM    第56节:codelyzer    第57节:electron-webpack    第58节:dot-dom    第59节:prerender    第60节:assemblyscript    第61节:jarvis    第62节:Rollup    第63节:webpack-dashboard    第64节:worker-plugin    第65节:webpack-encore    第66节:HEAD    第67节:poi    第68节:dawn    第69节:mustache.js    第70节:shipit    第71节:Flow    第72节:teletype    第73节:Dust.js    第74节:Athena    第75节:npm    第76节:Koala    第77节:webpackmonitor    第78节:ndm    第79节:size-plugin    第80节:seajs    第81节:prepack-webpack-plugin    第82节:webpack-simple-starter    第83节:Verdaccio    第84节:doT.js    第85节:bonsai    第86节:arttemplate    第87节:UiBot RPA    第88节:EJS    第89节:mern-starter    第90节:v8.dev    第91节:renovate    第92节:happypack    第93节:gulp    第94节:grunt    第95节:microbundle    第96节:handlebars.js    第97节:micro    第98节:tink    第99节:min-cli    第100节:Snibox    第101节:Codekit    第102节:WebAssembly    第103节:webpack-bundle-analyzer    第104节:htm    第105节:yeoman    第106节:Broccoli.js    第107节:jetpack    第108节:ied    第109节:Ender    第110节:Nunjucks    第111节:splittable    第112节:closure-compiler    第113节:react-boilerplate    第114节:SystemJS    第115节:electron-webpack-dashboard    第116节:fuse-box    第117节:jsvu    第118节:tmt-workflow    第119节:Cooking    第120节:hogan.js