Open Riunshow opened 6 years ago
<nav role="navigation" aria-label="primary"> <ul class="nav__list"> <li class="nav__list__item"> <a href="" class="nav__link"></a> </li> <li class="nav__list__item"> <a href="" class="nav__link--active"></a> </li> <li class="nav__list__item"> <a href="" class="nav__link"></a> </li> </ul> </nav>
nav[role="navigation"] { } .nav { &__list { &__item { } } &__link { &--active { } } }
nav[role="navigation"] { } .nav { } .nav__list { } .nav__list__item { } .nav__link { } .nav__link--active { }
先上一段代码 less
.opacity(@opacity: 100) { opacity: @opacity / 100; filter: ~"alpha(opacity=@{opacity})"; } .sidebar { .opacity(50); }
.sidebar { opacity: 0.5; filter: alpha(opacity=50); }
用预处理器把less、sass转为css,然后再通过Autoprefixer给编译好的css加前缀。
var autoprefixer = require('autoprefixer'); module.exports = { module: { loaders: [ { test: /\.less$/, loader: "style-loader!css-loader!postcss-loader!less-loader" } ] }, postcss: [ autoprefixer({ browsers: ['last 2 versions'] }) ] }
模块化 css
规范
预处理器
先上一段代码 less
webpack 配合插件
用预处理器把less、sass转为css,然后再通过Autoprefixer给编译好的css加前缀。