
Hampton Catlin
Sass Last version: v3.6.5
node-sass Last version: v6.0.1
Sass Last version: v3.6.5
node-sass Last version: v6.0.1
80% possibility SASS, LESS и Stylus equal,
20% difference.
How to install?
npm install -g sass
sass source/stylesheets/index.scss build/stylesheets/index.css
npm install -g less
lessc styles.less styles.css
npm install -g stylus
stylus -w style.styl -o style.css
Gulp, Webpack ...
Less / SCSS
body {
background-color: #efefef;
font-size: 100% Helvetica, sans-serif;
}
SASS
body
background-color: #efefef
font-size: 100% Helvetica, sans-serif
Stylus
body
background-color #efefef
font-size 100% Helvetica, sans-serif
Stylus maintains both types
$warning: #555;
$font-large: 24px;
div {
color: $warning;
font-size: $font-large;
}
@warning: #555;
@font-large: 24px;
div {
color: @warning;
font-size: @font-large;
}
warning = #555
font-large = 24px
div
color warning
font-size font-large
.block {
display: block;
&__element {
padding: 10px 5px;
&_modifier{
color: pink;
}
}
&_inline {
display: inline-block;
}
}
.block {
display: block;
&__element {
padding: 10px 5px;
&_modifier {
color: pink;
}
}
&_inline {
display: inline-block;
}
}
.block
display block
&__element
padding 10px 5px
&_modifier
color pink
&_inline
display inline-block
@import "reset.css";
@import "asset/variables.sass";
@import "component/nav/navbar.sass";
@import "reset.css"
@import "asset/variables.less"
@import "component/nav/navbar.less"
@import "reset.css"
@import "asset/variables.styl"
@import "component/nav/navbar.styl"
One for all
1cm * 1em => 1cm *em
2in * 3in => 6in *in
(1cm / 1em) * 4em => 4cm
2in + 3cm + 2pc => 3.514in
3in / 2in => 1.5
...
p {
margin: calc(1rem - 2px) calc(1rem - 1px);
}
@mixin bordered($width) {
border: $width solid #ddd;
&:hover {
border-color: #999;
}
}
div {
@include bordered(5px);
}
.bordered(@width) {
border: @width solid #ddd;
&:hover {
border-color: #999;
}
}
div {
.bordered(5px);
}
bordered(width)
border: width solid #ddd
&:hover
border-color: #999
div
bordered(5px)
.block {
margin: 10px 5px;
}
p {
@extend .block;
border: 1px solid #eee;
}
ul, ol {
@extend .block;
color: #333;
text-transform: uppercase;
}
.block {
margin: 10px 5px;
}
p {
&:extend(.block);
border: 1px solid #eee;
}
ul, ol {
&:extend(.block);
color: #333;
text-transform: uppercase;
}
.block
margin 10px 5px
p
@extend .block
border 1px solid #eee
ul, ol
@extend .block
color #333
text-transform uppercase
.awesome {
width: 100%;
height: 100%;
}
body {
@extend .awesome;
}
p {
@extend .awesome;
}
.awesome, body, p {
width: 100%;
height: 100%;
}
@mixin awesome($w: 100%) {
width: $w;
}
body {
@include awesome(960px);
}
p {
@include awesome;
}
body {
width: 960px;
}
p {
width: 100%;
}
@for $i from 1px to 3px {
.border-#{i} {
border: $i solid blue;
}
}
.loop(@counter) when (@counter > 0) {
.loop((@counter - 1));
.border-@{counter} {
border: 1px * @counter solid blue;
}
}
for num in (1..3)
.border-{num}
border 1px * num solid blue
$grid-columns: 12;
$grid-width: 960px;
@function calculate-column-width($cols) {
@return $grid-width / $grid-columns * $cols / $grid-width * 100%
}
#container {
margin: 0 auto;
width: 100%;
}
article {
float: left;
width: calculate-column-width(8);
}
aside {
float: right;
width: calculate-column-width(4);
}
@grid-columns: 12;
@grid-width: 960px;
.calculate-column-width(@cols) {
width: (((@grid-width / @grid-columns) * @cols / @grid-width) * 100%);
}
#container {
margin: 0 auto;
width: 100%;
}
article {
float: left;
.calculate-column-width(8);
}
aside {
float: right;
.calculate-column-width(4);
}
grid-columns 12
grid-width 960px
calculate-column-width(cols)
((grid-width / grid-columns) * cols / grid-width) * 100%)
#container
margin 0 auto
width 100%
article
float left
width calculate-column-width(8)
aside
float right
width calculate-column-width(4)
saturate($color, $amount)
desaturate($color, $amount)
lighten($color, $amount)
darken($color, $amount)
adjust-hue($color, $amount)
opacity($color, $amount)
transperentize($color, $amount)
mix($color1, $color2[, $amount])
grayscale($color)
complement($color)
saturate(@color, @amount)
desaturate(@color, @amount)
lighten(@color, @amount)
darken(@color, @amount)
adjust-hue(@color, @amount)
opacity(@color, @amount)
transperentize(@color, @amount)
mix(@color1, @color2, @weight)
grayscale(@color)
complement(@color)
red(color)
green(color)
blue(color)
alpha(color)
dark(color)
light(color)
hue(color)
saturation(color)
lightness(color)
:root {
--warning: #555;
--font-large: 24px;
}
div {
color: var(--warning);
font-size: var(--font-large);
}
@import "mystyle.css";
@import url("mystyle.css");
nav {
background: color-mod(#79d3e2 hue(360) saturation(100%));
}
1cm * 1em => 1cm *em
2in * 3in => 6in *in
(1cm / 1em) * 4em => 4cm
2in + 3cm + 2pc => 3.514in
3in / 2in => 1.5
...
p {
margin: calc(1rem - 2px) calc(1rem - 1px);
}
A Collection of Interesting Ideas, 18 September 2016
:root {
--toolbar-theme: {
background-color: hsl(120, 70%, 95%);
border-radius: 4px;
border: 1px solid var(--theme-color late);
};
--toolbar-title-theme: {
color: green;
};
}
.toolbar {
@apply --toolbar-theme;
}
.toolbar > .title {
@apply --toolbar-title-theme;
}
Editor’s Draft, 9 March 2019
.block {
display: block;
@nest element {
padding: 10px 5px;
& modifier {
color: pink;
}
}
& inline {
display: inline-block;
}
}
A Collection of Interesting Ideas, 15 January 2015
.block, p, ul, ol {
margin: 10px 5px;
}
p {
border: 1px solid #eee;
}
ul, ol {
color: #333;
text-transform: uppercase;
}
.accordion {
$accordion-header-color: $primary-color;
$accordion-padding: 1em;
@extend %module;
@include transition(all 0.3s ease-out);
background: $accordion-header-color;
padding: $accordion-padding;
}
.filters-block {
$_filter-height: 20px;
@mixin _note-size($value) {
height: $value;
line-height: $value;
margin-top: -($value);
}
&__list {
height: $_filters-height * 7;
overflow: auto;
}
&__item {
height: $_filter-height;
}
&__note {
@include _note-size(30px);
}
@media screen and (max-width 1000px) {
&__note {
@include _note-size(40px);
}
}
}
Last version: 7.0.17 released (5 June, 2019)
module.exports = postcss.plugin('postcss-carl', function (opts) {
return function (css, result) {
css.walkRules(function(rule) {
rule.selector = rule.selector + ', CARL';
});
};
});
var postcss = require('postcss');
postcss([
require('autoprefixer'),
require('stylelint')({
syntax: 'scss'
})
])
.process(css)
.then(result => console.log(result.css))
module.exports = {
module: {
loaders: [{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: [{
loader: 'css-loader',
options: { importLoaders: 1 },
},
'postcss-loader'
]}),
}]},
plugins: {
'postcss-import': {},
'postcss-cssnext': {
browsers: ['last 2 versions', '> 5%'],
}},
};
var StyleLintPlugin = require('stylelint-webpack-plugin');
module.exports = {
// ...
plugins: [
new StyleLintPlugin({
/* Options */
configFile: '.stylelintrc'
}),
],
// ...
}