获取和设置CSS样式表规则的JavaScript库:JSS

jopen 10年前

一个简单的JavaScript库,用来读取和设置CSS样式表的规则。

  • Tiny - only 4KB minified
  • No dependencies
  • MIT Licensed
  • 支持 FF, Chrome, Safari, Opera, and IE9+

为什么利用JavaScript生成CSS?

  • To set styles that need to be calculated or retrieved
  • To set behavioural styles for your widget or plugin so that consumers aren't forced to include a stylesheet for core functionality
  • To dynamically apply styles without cluttering your HTML (as is the case with inline styles)
  • To set styles on all current and future elements

jss.get([selector]) to retrieve rules added via JSS:    jss.get('.demo');  // returns the following:  {      'font-size': '15px',      'color': 'red'  }    jss.get();  // returns the following:  {      '.demo': {          'font-size': '15px',          'color': 'red'      }  }

项目主页:http://www.open-open.com/lib/view/home/1408525419334