introduce

A minimalist and lightweight Sass tool library, including Sass mixes, functions, default variables, etc.

Naming conventions

BEM naming.

Method of use

#The installation
$ npm install --save sass-utilsCopy the code

/* Import */ in the sass file
@import "~sass-utils";

.selector {
/* Call mix */
  @include position--relative;
  
/* Use default variables to set the font */
  font-family: $font-family-english;
}

/* Rewrites the function to make it easier to call */
$colors: red yellow;

@function color($index) {
  @return _color($colors.$index);
}Copy the code

text–middle

The text is centered vertically.

// sass
.selector {
  @include text--middle(100px);
}Copy the code

// css
.selector {
  height: 100px;
  line-height: 100px;
} Copy the code

link–block

Block links.

// sass
.selector {
  @include link--block(100px. 200px);
}Copy the code

// css
.selector {
  display: block;
  text-decoration: none;
  width: 100px;
  height: 200px;  
}Copy the code

_font

Font. Need to be rewritten in business code for easy invocation.

// sass
$fonts: (12px) (13px bold);

@mixin font($index) {
  @include _font($fonts.$index);
}

.selector {
  @include font(2);
}Copy the code

// css
.selector {
  font-size: 13px;
  font-weight: bold;
}

[data-dpr="2"] .selector {
  font-size: 26px;
}

[data-dpr="3"] .selector {
  font-size: 39px;
}Copy the code

e

BEM element.

clearfix

Clear the float.

// sass
.selector {
  @include clearfix;
}Copy the code

// css
.selector::before..selector::after {
  content: "";
  display: table;
}

.selector::after {
  clear: both;
}Copy the code

padding

Sets the padding.

// sass
.selector {
  @include padding(100px. 200px.null. 400px);
}Copy the code

// css
.selector {
  padding-top: 100px;
  padding-right: 200px;
  padding-left: 400px;  
}Copy the code

only-ie8

Only Internet Explorer 8 is available.

// sass
.selector {
  @include only-ie8(display.inline);
}Copy the code

// css
.selector {
  display: inline\9;
}Copy the code

position–absolute

Absolute positioning.

// sass
.selector {
  @include position--absolute(100px. 200px);
}Copy the code

// css
.selector {
  position: absolute;
  top: 100px;
  right: 200px;
}Copy the code

inline–block

Compatible with IE8 display: inline-block.

// sass
$supports-ie8: true;

.selector {
  @include inline--block;
}Copy the code

// css
.selector {
  display: inline-block;
  display: inline\9;
  zoom: 1\9;  
}Copy the code

Functions

_color

Get the color. Need to be rewritten in business code for easy invocation.

// sass
$colors: yellow red;

@function color($index) {
  @return _color($colors.$index);
}

.selector {
  color: color(2);
}Copy the code

// css
.selector {
  color: red;
}Copy the code

$font-family

Chinese font.

$font-family-english

English font.

$separator-modifier

BEM Modifier delimiter.