Susy提供了一個簡單的語法來輕鬆地將任意設置傳遞到函數(function)和混合宏(mixin)中。想要徹底掌握Susy2,Shorthand
很關鍵。css
Shorthand: $span $grid $keywords;複製代碼
span 能夠是任何長度的跨列。shell
grid 是列(column)
的設置的,並且還能夠設置gutter
、column-width
,例如:bootstrap
// 12列
$grid: 12;
// 12列,gutter爲1/3
$grid: 12 1/3;
// 12列,列寬60px,gutter10px
$grid: 12 (60px 10px);
// 按 1:2:3:2:1比例分12列,gutter爲1/4
$grid: (1 2 3 2 1) .25;複製代碼
keyword比較容易,幾乎全部設置都帶有keyword
,由於是map類型,能夠無序的寫入,先看一下全局的:ide
$global-keywords: (
container : auto,
math : static fluid,
output : isolate float,
container-position : left center right,
flow : ltr rtl,
gutter-position : before after split inside inside-static,
debug: (
image : show hide show-columns show-baseline,
output : background overlay,
),
);
$local-keywords: (
box-sizing : border-box content-box,
edge : first alpha last omega,
spread : narrow wide wider,
gutter-override : no-gutters no-gutter,
clear : break nobreak,
role : nest,
);複製代碼
<grid>
<keywords>
// grid: (columns: 4, gutters: 1/4, column-width: 4em);
// keywords: (math: fluid, gutter-position: inside-static, flow: rtl);
$demo: 4 (4em 1em) fluid inside-static rtl;
$result : layout($demo);
// 打印輸出
@debug $result;
// (math: fluid, gutter-position: inside-static, flow: rtl, columns: 4, gutters: 0.25, column-width: 4em)複製代碼
Susy2 有大量計算或設置寬度的函數和混合宏,因此建立span的簡寫配置會比較經常使用。函數
<span>
at <location>
of <layout>
// span: 3;
// location: 4;
// layout: (columns: 12, gutters: .25, math: fluid)
$span: 3 at 4 of 12 .25 fluid;
// Only $span is required in most cases
$span: 30%;複製代碼
預告:下一篇:經過Susy2
打造bootstrap
柵格系統ui