Skip to content
This repository was archived by the owner on Jul 18, 2024. It is now read-only.

Commit 9ac6408

Browse files
authored
Merge pull request #31 from IBM/v2.0.0
v2.0.0
2 parents c5c3ff2 + a4b17a2 commit 9ac6408

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4668
-2510
lines changed

examples/bootstrap/css-gridish/README.md

Lines changed: 81 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ The Chrome extension uses the same shortcuts. To set the extension up:
1919

2020
## Legacy Support
2121

22-
If you have no need to support browsers like IE 11 and Edge <15, please use `css/bootstrap-grid.min.css` and ignore the legacy classes below for efficiency’s sake.
22+
If you have no need to support browsers like IE 11 and Edge <15, please use `css/bootstrap-grid.min.css`. This will omit the CSS Flexbox fallback from your code.
2323

24-
If you are supporting browsers that lack [CSS Grid Layout support](https://developer.mozilla.org/en-US/docs/Web/CSS/grid#Browser_compatibility), you can use `css/bootstrap-grid-legacy.min.css` and the legacy classes below. With the legacy file and classes, the browsers that do not support the final CSS Grid Legacy spec will fallback to a flexbox alternative. The flexbox alternative supports embedded subgrids that still reflect the overall grid system’s column structure.
24+
If you are supporting browsers that lack [CSS Grid Layout support](https://developer.mozilla.org/en-US/docs/Web/CSS/grid#Browser_compatibility), you can use `css/bootstrap-grid-legacy.min.css` and the legacy classes below. With the legacy file, the browsers that do not support the final CSS Grid Legacy spec will fallback to a flexbox alternative. The flexbox alternative supports embedded subgrids that still reflect the overall grid system’s column structure.
2525

2626
### Transitioning from Legacy
2727

@@ -64,36 +64,25 @@ If you are new to CSS Grid, please try [learning the basics](https://www.google.
6464
| ----------------------------------------- | ------------------------------------------------------------------------------------------ |
6565
| `.bootstrap-container` | Container element of whole page for proper margin and max-width (can be used on body tag ) |
6666
| `.bootstrap-container--[left, right]` | Align the container element to the left or right side |
67+
| `.bootstrap-container__bleed--[sm]` | Extend the background color of a container child into the container margin on both sides starting at a specific breakpoint (CSS Grid browsers only) |
68+
| `.bootstrap-container__bleed--[sm]--[left, right]` | Extend the background color of a grid into the container margin on one side at a specific breakpoint (CSS Grid browsers only) |
69+
| `.bootstrap-container__break--[sm]` | Child of container element should ignore grid’s margin at a specific breakpoint (CSS Grid browsers only) |
70+
| `.bootstrap-container__break--[sm]--[left, right]` | Child of container element should ignore grid’s margin on one side at a specific breakpoint (CSS Grid browsers only) |
6771
| `.bootstrap-grid` | Use anytime you want to apply CSS Grid Layout, including as embedded subgrids |
68-
| `.bootstrap-grid--bleed` | To extend the background color of a grid into the margin of the body on both sides |
69-
| `.bootstrap-grid--bleed--[left, right]` | To extend the background color of a grid into the margin of the body on one side |
7072
| `.bootstrap-grid--fixed-columns` | Switch grid’s column widths to fixed instead of fluid |
7173
| `.bootstrap-grid--fluid-rows` | Switch grid’s row height to match the width of a column |
72-
| `.bootstrap-grid__break--[left, right]` | Direct child of container element should ignore grid’s margin. Not supported for legacy. |
7374
| `.bootstrap-padding` | Add one unit of padding to element on all sides |
7475
| `.bootstrap-padding--[bottom, left, right, top]` | Add one unit of padding to element on one side |
7576
| `.bootstrap-padding--[horizontal, vertical]` | Add one unit of padding to element on two sides |
76-
77-
By default, the grid code uses fluid columns and fixed rows. You can switch both aspects with `.bootstrap-grid--fixed-columns` and `.bootstrap-grid--fluid-rows`.
78-
79-
### Legacy
80-
81-
The following classes are only necessary if supporting browsers that do not have [CSS Grid Layout support](https://developer.mozilla.org/en-US/docs/Web/CSS/grid#Browser_compatibility). The previous classes are also necessary for modern browsers.
82-
83-
Please remember that the classes below have no affect on browsers that have [CSS Grid Layout support](https://developer.mozilla.org/en-US/docs/Web/CSS/grid#Browser_compatibility).
84-
85-
| Class Name | Purpose |
86-
| ----------------------------------------- | ------------------------------------------------------------------------------------------ |
8777
| `.bootstrap-grid__col--sm--[1-12]` | Set the width out of 12 columns for an item in the grid starting at the sm breakpoint |
8878
| `.bootstrap-grid__col--[sm]--0` | Do not display item at a specific breakpoint, but display at the next breakpoint with columns specified |
8979
| `.bootstrap-grid__col--[sm]--0--only` | Do not display item only at specific breakpoint |
90-
| `.bootstrap-grid__height-fixed--[sm]--[1-30]` | Set the min-height based on an interval of 15px for an item starting at the breakpoint specified |
91-
| `.bootstrap-grid__height-fluid--sm--[1-12]` | Set the min-height on the width of 1-12 columns for an item starting at the sm breakpoint |
80+
| `.bootstrap-grid__height--[sm]--[1-30]` | Set the min-height based on an interval of 15px for an item starting at the breakpoint specified |
9281
| `.bootstrap-grid__height--[sm]--0` | Reset the min-height for an item starting at the specified breakpoint |
9382

94-
The legacy `.bootstrap-grid__height-fixed--[sm]--[1-30]` class follows the numbering system as described in our height variables](#Fixed Height).
83+
By default, the grid code uses fluid columns and fixed rows. You can switch both aspects with `.bootstrap-grid--fixed-columns` and `.bootstrap-grid--fluid-rows`. When switching to fluid rows, the rows will scale across breakpoints just like `col` classes and only supports quantities up to the amount of columns in that breakpoint.
9584

96-
If you follow the instructions above for custom breakpoints, all of these legacy classes will generate with a version for each custom breakpoint too. For example, adding the custom breakpoint of `35` will create `.bootstrap-grid__col--35--1` and `.bootstrap-grid__height-fixed--35--1`. Since that custom breakpoint is right after the previous breakpoint, it will have the same amount of columns and min-height.
85+
If you follow the instructions above for custom breakpoints, all of the `col` and `height` classes will generate with a version for each custom breakpoint too. For example, adding the custom breakpoint of `whateversize` will create `.bootstrap-grid__col--whateversize--1`. Since that custom breakpoint is right after the previous breakpoint, it will have the same amount of columns and min-height.
9786

9887
## Variables
9988

@@ -120,6 +109,77 @@ We provide the fixed height variables for items that are not direct children of
120109
}
121110
```
122111

112+
## Mixins and Functions
113+
114+
### Media Query Mixin
115+
116+
You can use the media query mixin to use breakpoints you’ve defined.
117+
118+
**Example SCSS**
119+
```scss
120+
button {
121+
@include media-query('sm') {
122+
border: 2px solid hotpink;
123+
}
124+
}
125+
```
126+
127+
**Output CSS**
128+
```css
129+
@media screen and (min-width: 20rem) {
130+
button {
131+
border: 2px solid hotpink;
132+
}
133+
}
134+
```
135+
136+
You can then **combine this mixin with the functions below** to construct media queries that set fluid and fixed sizes based on this grid.
137+
138+
### Get a Fluid Size
139+
140+
Use the `get-fluid-size()` SCSS function to calculate a fluid width based on: (1) a defined breakpoints, and (2) a number of columns to span, relative to the number of available columns for the given breakpoint.
141+
142+
**Example SCSS**
143+
```scss
144+
@media screen and (min-width: 20rem) {
145+
button {
146+
@include media-query('sm') {
147+
max-width: get-fluid-size('sm', 1);
148+
}
149+
}
150+
}
151+
```
152+
153+
**Output CSS**
154+
```css
155+
@media screen and (min-width: 20rem) {
156+
button {
157+
max-width: 25vw;
158+
}
159+
}
160+
```
161+
162+
### Get a Fixed Size
163+
Use the `get-fixed-size()` SCSS function to calculate a fixed size based on a number of fixed nondimensional units multiplied by the base value from the current row height of the grid (`$rowHeight`);
164+
165+
**Example SCSS**
166+
```scss
167+
button {
168+
@include media-query('sm') {
169+
max-width: get-fixed-size(10);
170+
}
171+
}
172+
```
173+
174+
**Output CSS**
175+
```css
176+
@media screen and (min-width: 20rem) {
177+
button {
178+
max-width: 5rem;
179+
}
180+
}
181+
```
182+
123183
## FAQs
124184

125185
### Why does none of the CSS Grid code use `grid-gap` for gutters?
@@ -138,7 +198,7 @@ it is difficult for you to write semantic HTML with CSS Grid Layout. We are
138198
able to take advantage of vw units and the calc function so you can embed
139199
`.bootstrap-grid` elements inside of each other and still respect the overall grid design.
140200

141-
### Why are there no row classes for the legacy implementation?
201+
### Why are there no grouping row classes needed?
142202

143203
Thanks to flexbox’s wrapping functionality, nodes that specify rows are not necessary. Only create a node for a row if it has semantic or accessibility significance. You can keep embedding `.bootstrap-grid` as necessary to accomplish this.
144204

Binary file not shown.

0 commit comments

Comments
 (0)