Every project will require the following variable map to be defined:
$g-config: (
maxWidth: 1020px,
tabletWidth: 720px,
columnPadding: 15px,
gutter: 20px
);
There are two ways you can implement a grid in your layout:
- Via HTML classes
- Via SASS mixins
Neither is more correct that the other. It all depends on your use case. The CSS route is perhaps cleaner, but may be more work if you have to name addtional components to style.
Column widths and break rules are defined as classes in the HTML.
<div class="Layout G-container">
<div class="G-row">
<div class="G-col-4 G-col-mobile--12">
<!-- content goes here -->
</div>
<div class="G-col-8 G-col-mobile--12">
<!-- content goes here -->
</div>
</div>
</div>
Elements are assigned classes in the HTML but the column widths and break rules are defined in the SASS/CSS using mixins.
<div class="Layout">
<div class="Layout-inner">
<div class="Sidebar">
<!-- content goes here -->
</div>
<div class="Content">
<!-- content goes here -->
</div>
</div>
</div>
.Layout {
@include g();
.Layout-inner {
@include g-row();
}
.Sidebar {
@include g-col(4);
@include g-when-mobile {
@include g-col(12);
}
}
.Content {
@include g-col(8);
@include g-when-mobile {
@include g-col(12);
}
}
}
@include g($fluid: false, $flush: false, $gutter: true);
@include g-row();
@include g-column($columns);
@include g-when-mobile() {
// Styles here
}
@include g-when-tablet() {
// Styles here
}
@include g-when-desktop() {
// Styles here
}
<div class="G-container G-container--fluid">
<!-- content goes here -->
</div>
<div class="G-container G-container--fluid">
<!-- content goes here -->
</div>
<div class="G-container G-container--flush">
<!-- content goes here -->
</div>
<div class="G-container G-container--gutterless">
<!-- content goes here -->
</div>