hacks-guide-minimal-mistake.../_assets/css/_mixins.scss

113 lines
2.3 KiB
SCSS
Raw Normal View History

2015-01-20 21:25:57 +01:00
/* ==========================================================================
2016-03-10 17:13:54 +01:00
MIXINS
2015-01-20 21:25:57 +01:00
========================================================================== */
2016-03-10 17:13:54 +01:00
%tab-focus {
// Default
outline: thin dotted $warning-color;
// Webkit
outline: 5px auto $warning-color;
2014-07-31 19:09:32 +02:00
outline-offset: -2px;
}
2015-04-17 12:43:36 +02:00
/*
2016-03-10 17:13:54 +01:00
em function
2015-01-20 21:25:57 +01:00
========================================================================== */
2016-03-10 17:13:54 +01:00
@function em($target, $context: $doc-font-size) {
@return ($target / $context) * 1em;
2014-07-31 19:09:32 +02:00
}
2015-01-20 21:25:57 +01:00
2015-04-17 12:43:36 +02:00
/*
2016-03-10 17:13:54 +01:00
Bourbon clearfix
2015-01-20 21:25:57 +01:00
========================================================================== */
2014-07-31 19:09:32 +02:00
2016-03-10 17:13:54 +01:00
// Provides an easy way to include a clearfix for containing floats.
//
// @link http://cssmojo.com/latest_new_clearfix_so_far/
//
// @example scss - Usage
// .element {
// @include clearfix;
// }
//
// @example css - CSS Output
// .element::after {
// clear: both;
// content: "";
// display: table;
// }
2014-07-31 19:09:32 +02:00
2016-03-10 17:13:54 +01:00
@mixin clearfix {
2016-03-11 21:55:06 +01:00
clear: both;
2016-03-10 17:13:54 +01:00
&::after {
clear: both;
content: "";
display: table;
}
2015-01-20 21:25:57 +01:00
}
2015-04-17 12:43:36 +02:00
/*
2016-03-10 17:13:54 +01:00
Grid
2015-01-20 21:25:57 +01:00
========================================================================== */
2014-07-31 19:09:32 +02:00
2016-03-10 17:13:54 +01:00
@mixin container() {
margin: 0 auto;
width: $width;
2015-01-20 21:25:57 +01:00
}
2014-07-31 19:09:32 +02:00
2016-03-10 17:13:54 +01:00
// Works out the width of elements based on total number of columns and width
// number of columns being displayed. Removes 20px for margins.
2015-01-20 21:25:57 +01:00
2016-03-10 17:13:54 +01:00
@mixin grid($grid:$def_grid,$cols:'',$float:left,$display:inline) {
display: $display;
float: $float;
width: (100%/$grid * $cols) - ($margin * 2);
2015-01-20 21:25:57 +01:00
}
2016-03-10 17:13:54 +01:00
// Add x amount of column padding before an element
// Example: @include prefix(1,12);
2014-07-31 19:09:32 +02:00
2016-03-10 17:13:54 +01:00
@mixin prefix($grid:$def_grid,$cols:'') {
margin-left: (100%/$grid * $cols);
2015-01-20 21:25:57 +01:00
}
2016-03-10 17:13:54 +01:00
// Add x amount of column padding after an element
// Example: @include suffix(2,12);
2015-01-20 21:25:57 +01:00
2016-03-10 17:13:54 +01:00
@mixin suffix($grid:$def_grid,$cols:'') {
margin-right: (100%/$grid * $cols);
2015-01-20 21:25:57 +01:00
}
2016-03-10 17:13:54 +01:00
// Remove left margin
// Example: @include first;
2014-07-31 19:09:32 +02:00
2016-03-10 17:13:54 +01:00
@mixin first() {
margin-left: 0;
2015-01-20 21:25:57 +01:00
}
2016-03-10 17:13:54 +01:00
// Remove right margin
// Example: @include last;
2014-07-31 19:09:32 +02:00
2016-03-10 17:13:54 +01:00
@mixin last() {
margin-right: 0;
2014-07-31 19:09:32 +02:00
}
2016-03-10 17:13:54 +01:00
// Push an element x amount of column(s) to the right
// Example: @include push(2,12);
2015-01-20 21:25:57 +01:00
2016-03-10 17:13:54 +01:00
@mixin push($grid:$def_grid,$move:'') {
position: relative;
left: (100%/$grid * $move);
2015-01-20 21:25:57 +01:00
}
2016-03-10 17:13:54 +01:00
// Pull an element x amount of column(s) to the left
// Example: @include pull(1,12);
2014-07-31 19:09:32 +02:00
2016-03-10 17:13:54 +01:00
@mixin pull($grid:$def_grid,$move:'') {
position: relative;
left: (100%/$grid * $move) * -1;
2015-01-20 21:25:57 +01:00
}