Skip to content

Instantly share code, notes, and snippets.

@RafaelCz
Last active September 12, 2015 15:04
Show Gist options
  • Select an option

  • Save RafaelCz/06c06494e97f49b343ee to your computer and use it in GitHub Desktop.

Select an option

Save RafaelCz/06c06494e97f49b343ee to your computer and use it in GitHub Desktop.
usefull mixins for Sass
/* Set a rem font size with pixel fallback */
@function calculateRem($size) {
$remSize: $size / 16px;
@return $remSize * 1rem;
}
@mixin font-size($size) {
font-size: $size;
font-size: calculateRem($size);
}
/* border radius */
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}
/* Transitions */
@mixin transition($args...) {
-webkit-transition: $args;
-moz-transition: $args;
-ms-transition: $args;
-o-transition: $args;
transition: $args;
}
/* Clearfix
Usage:
.container-with-floated-children {
@extend %clearfix;
} */
%clearfix {
*zoom: 1;
&:before, &:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
}
/* Animations and keyframes */
@mixin keyframes($animation-name) {
@-webkit-keyframes $animation-name {
@content;
}
@-moz-keyframes $animation-name {
@content;
}
@-ms-keyframes $animation-name {
@content;
}
@-o-keyframes $animation-name {
@content;
}
@keyframes $animation-name {
@content;
}
}
@mixin animation($str) {
-webkit-animation: #{$str};
-moz-animation: #{$str};
-ms-animation: #{$str};
-o-animation: #{$str};
animation: #{$str};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment