Advertisement
Guest User

SCSS flexbox helper

a guest
Feb 15th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 1.79 KB | None | 0 0
  1. @mixin flexible ($vertically: center, $horizontally: center, $direction: row) {
  2.    
  3.     display: -webkit-box;
  4.     display: -webkit-flex;
  5.     display: -moz-flex;
  6.     display: -ms-flexbox;
  7.   display: flex;
  8.        
  9.     /* vertical align */
  10.     @if $vertically == "center" {
  11.             align-items: center;
  12.             -webkit-align-align-items: center;
  13.             -moz-align-items: center;
  14.  
  15.     } @else if $vertically == "bottom" {
  16.             align-items: flex-end;
  17.             -webkit-align-align-items: center;
  18.             -moz-align-items: center;
  19.  
  20.     } @else if $vertically == "top" {
  21.             align-items: flex-start;
  22.             -webkit-align-align-items: center;
  23.             -moz-align-items: center;
  24.  
  25.     } @else {
  26.             align-items: $vertically;
  27.             -webkit-align-items: $vertically;
  28.             -moz-align-items: $vertically;
  29.  
  30.     }
  31.  
  32.     /* horizontal align */
  33.     @if $horizontally == "center" {
  34.  
  35.             justify-content: center;
  36.             -webkit-justify-content: center;
  37.             -moz-justify-content: center;
  38.  
  39.     } @else if $horizontally == "right" {
  40.             justify-content: flex-end;
  41.             -webkit-justify-content: flex-end;
  42.             -moz-justify-content: flex-end;
  43.  
  44.     } @else if $horizontally == "left" {
  45.             justify-content: flex-start;
  46.             -webkit-justify-content: flex-start;
  47.             -moz-justify-content: flex-start;
  48.  
  49.     } @else {
  50.             justify-content: $horizontally;
  51.             -webkit-justify-content: $horizontally;
  52.             -moz-justify-content: $horizontally;
  53.     }
  54.        
  55.     @if $direction == "column" {
  56.         -webkit-flex-direction: $direction;
  57.         -moz-flex-direction: $direction;
  58.         -ms-flex-direction:$direction;
  59.         flex-direction: $direction;
  60.  
  61.     } @else if $direction "row" {
  62.         -webkit-flex-direction: row;
  63.         -moz-flex-direction: row;
  64.         -ms-flex-direction: row;
  65.         flex-direction: row;
  66.  
  67.     } @else {
  68.         -webkit-flex-direction: $direction;
  69.         -moz-flex-direction: $direction;
  70.         -ms-flex-direction: $direction;
  71.         flex-direction: $direction;
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement