獲取和設置CSS樣式表規則的JavaScript庫:JSS

jopen 10年前發布 | 16K 次閱讀 JSS 前端技術

一個簡單的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.baiduhome.net/lib/view/home/1408525419334

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!