Functions, mixins and placeholders for speed up your development process.
npm install @ederssouza/sass-helpers --save-dev
Import the global index.scss
file in your project.
@import '~@ederssouza/sass-helpers';
See mixins.scss.
.icon {
width: 100px;
height: 100px;
background-color: red;
@include animation(changeBg 4s);
}
@include keyframes(changeBg) {
from {background-color: red;}
to {background-color: yellow;}
}
.icon {
width: 100px;
height: 100px;
background-color: red;
-webkit-animation: changeBg 4s;
-moz-animation: changeBg 4s;
animation: changeBg 4s;
}
@-webkit-keyframes changeBg {
from {
background-color: red;
}
to {
background-color: yellow;
}
}
@-moz-keyframes changeBg {
from {
background-color: red;
}
to {
background-color: yellow;
}
}
@keyframes changeBg {
from {
background-color: red;
}
to {
background-color: yellow;
}
}
.container {
@include background-size(cover);
}
.container {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.container {
@include border-radius(4px);
}
.container {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.container {
@include box-shadow(1px 1px 2px rgba(#000, .8));
}
.container {
-webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
-moz-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}
$fonts-dir: '../fonts';
@include font-face('Roboto', 'roboto', 'regular');
@font-face {
font-family: "Roboto";
src: url("../fonts/regular/roboto.eot");
src: url("../fonts/regular/roboto.eot?#iefix") format("embedded-opentype"), url("../fonts/regular/roboto.woff") format("woff"), url("../fonts/regular/roboto.ttf") format("truetype"), url("../fonts/regular/roboto.svg#Roboto") format("svg");
}
.container {
@include linear-gradient(red, orange);
}
.container {
background: orange;
background: -moz-linear-gradient(top, red 0%, orange 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, red), color-stop(100%, orange));
background: -webkit-linear-gradient(top, red 0%, orange 100%);
background: -o-linear-gradient(top, red 0%, orange 100%);
background: linear-gradient(to bottom, red 0%, orange 100%);
}
.container {
@include opacity(.5);
}
.container {
opacity: 0.5;
filter: alpha(opacity=50);
}
input, textarea {
@include placeholder {
font-style:italic;
}
}
input::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
font-style: italic;
}
input::-moz-placeholder, textarea::-moz-placeholder {
font-style: italic;
}
input:-moz-placeholder, textarea:-moz-placeholder {
font-style: italic;
}
input:-ms-input-placeholder, textarea:-ms-input-placeholder {
font-style: italic;
}
pre {
@include tab-size(2);
}
pre {
-webkit-tab-size: 2;
-moz-tab-size: 2;
-o-tab-size: 2;
tab-size: 2;
}
.icon {
@include transform(scale(1.5));
}
.icon {
-webkit-transform: scale(1.5);
-moz-transform: scale(1.5);
-ms-transform: scale(1.5);
transform: scale(1.5);
}
button {
background-color: #fff;
@include transition(background-color .26s);
&:hover {
background-color: #333;
}
}
button {
background-color: #fff;
-webkit-transition: background-color 0.26s;
-moz-transition: background-color 0.26s;
-o-transition: background-color 0.26s;
transition: background-color 0.26s;
}
button:hover {
background-color: #333;
}
.icon {
height: 100px;
width: 100px;
@include center-vertical;
}
.icon {
height: 100px;
width: 100px;
left: 50%;
position: absolute;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
$img-dir: '../img';
.icon {
@include sprite('sprite-icon.png', '0 50px', 50px, 50px);
}
.icon {
background-image: url("../img/sprite-icon.png");
background-position: "0 50px";
height: 50px;
width: 50px;
}
See functions.scss.
$browser-context: 16;
.container {
font-size: em(14)
}
.container {
font-size: 0.875em;
}
See placeholders.scss.
.container {
@extend %center-block;
}
.container {
display: block;
margin-left: auto;
margin-right: auto;
}
.container {
@extend %clearfix;
}
.container:before,
.container:after {
clear: both;
content: "";
display: block;
}
MIT License © Eder Sampaio