Notes
  • 速记
  • 前端面试
  • HTML / CSS
    • HTML
    • CSS
    • CSS Modules
      • CSS Modules
        • CSS Modules Usage
      • Stylus
      • Nunjucks
  • Javascript
    • 正则表达式
    • 代理(Proxy)和反射(Reflection)
    • 类型转换
    • 按位操作
    • 数据可视化
    • 数据采集
      • 无(全)埋点
      • 模块曝光事件
    • package
      • axios
    • Event Loop
    • React
      • React热身
      • VDOM和DOM-diff
    • Vue
    • Omi
    • MVVM
    • 百度小程序
    • AST抽象语法树
    • ServiceWorker
    • WebSocket
  • NodeJS
    • Assert 断言
    • chai.js 断言库
    • Node Global Obj And Var
    • CLI Writed By Nodejs
    • Framework
      • Hapi Js Framework
    • Electrode JS
      • Electrode Platform
      • Electrode Question
    • Redux
      • Redux Basic Usage
      • Middleware And Asynchronous
      • React-Redux 的用法
    • NPM
      • package.json
      • semver
    • Webpack
      • 编写插件
    • 同构渲染
    • 调用DLL
  • 服务端
    • Inotify
    • Linux
    • Nginx
      • Nginx简介
      • Nginx原理、安装预配置
    • TCP/IP 协议
    • HTTP 协议
      • 基础概念篇
      • 协议详解篇
    • Process
      • 阻塞与非阻塞
      • 进程与线程优性能
  • 数据库
    • GraphQL
  • 移动端
  • 微信小程序
    • 微信小程序安装(linux)
    • 小程序第三方框架
  • 开发工具
    • 开发工具安装
    • Vim Command Collection
    • Git
      • Git Rule
      • Git Submodule
      • gitignore
    • Lerna
    • Ubuntu开发环境安装
  • 运维测试
    • Docker
      • Docker Synopsis
      • docker.sock
    • Nightwatch
    • Jest
  • 算法/数学/架构
    • 设计模式
    • 架构设计经验分享
    • 前端架构
    • 基本数据结构
    • 函数式编程
  • 软件工程
    • 软件生命周期
Powered by GitBook
On this page
  • Nesting
  • Flexible syntax
  • Parent reference
  • Mixins
  • Transparent mixins
  • Variables
  • Block property access
  • Robust feature-rich language
  • Iteration
  • Interpolation
  • Operators
  • Type coercion
  • The sprintf operator
  • Color operations
  • Functions
  • Keyword arguments
  • Built-in functions
  • Color BIFs

Was this helpful?

  1. HTML / CSS
  2. CSS Modules

Stylus

Nesting

selector nesting enables you to keep your styles DRY:

body {
  font: 14px/1.5 Helvetica, arial, sans-serif;
#logo {
  border-radius: 5px;
  }
  }

  body {
    font: 14px/1.5 Helvetica, arial, sans-serif;
  }
  body #logo {
    border-radius: 5px;
   }

Flexible syntax

body
  font 14px/1.5 Helvetica, arial, sans-serif
  button
  button.button
  input[type='button']
  input[type='submit']
    border-radius 5px

body {
  font: 14px/1.5 Helvetica, arial, sans-serif;
}
body button,
body button.button,
body input[type='button'],
body input[type='submit'] {
  border-radius: 5px;
}

Parent reference

ul
  li a
    display: block
    color: blue
    padding: 5px
    html.ie &
      padding: 6px
    &:hover
      color: red

ul li a {
  display: block;
  color: #00f;
  padding: 5px;
}
html.ie ul li a {
  padding: 6px;
}
ul li a:hover {
  color: #f00;
}

Mixins

Transparent mixins

Variables

Block property access

#prompt
  position: absolute
  top: 150px
  left: 50%
  width: 200px
  margin-left: -(@width / 2)

#prompt {
  position: absolute;
  top: 150px;
  left: 50%;
  width: 200px;
  margin-left: -100px;
}

Robust feature-rich language

-pos(type, args)
  i = 0
  position: unquote(type)
  {args[i]}: args[i + 1] is a 'unit' ? args[i += 1] : 0
  {args[i += 1]}: args[i += 1] is a 'unit' ? args[i += 1] : 0

absolute()
  -pos('absolute', arguments)

fixed()
  -pos('fixed', arguments)

#prompt
  absolut: top 150 left 5px
  width: 200px
  margin-left: -(@width / 2)

#logo
  fixed: top left

#prompt {
  position: absolute;
  top: 150px;
  left: 5px;
  width: 200px;
  margin-left: -100px;
}

#logo {
position: fixed;
top: 0;
left: 0;
}

Iteration

table
  for row in 1 2 3 4 5
    tr:nth-chihld({row})
      height: 10px * row

table tr:nth-child(1) {
  height: 10px; 
}
table tr:nth-child(2) {
  height: 20px;
}
...
table tr:nth-child(5) {
  height: 50px;
}

Interpolation

Operators

Type coercion

The sprintf operator

body
  foo: '%s / %s' % (5px 10px)
  foo: 'MS:WeirdStuff(opacity=%s)' % 1
  foo: unquote('MS:WeirdStuff(opacity=1)')

body {
  foo: 5px / 10px;
  foo: MS:WeridStuff(opacity=1);
  foo: MS:WeirdStuff(opacity=1);
}

Color operations

Functions

Keyword arguments

Built-in functions

Color BIFs

PreviousCSS Modules UsageNextNunjucks

Last updated 5 years ago

Was this helpful?