You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 18, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: examples/bootstrap/css-gridish/README.md
+81-21Lines changed: 81 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -19,9 +19,9 @@ The Chrome extension uses the same shortcuts. To set the extension up:
19
19
20
20
## Legacy Support
21
21
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.
23
23
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.
25
25
26
26
### Transitioning from Legacy
27
27
@@ -64,36 +64,25 @@ If you are new to CSS Grid, please try [learning the basics](https://www.google.
|`.bootstrap-container`| Container element of whole page for proper margin and max-width (can be used on body tag ) |
66
66
|`.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) |
67
71
|`.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 |
70
72
|`.bootstrap-grid--fixed-columns`| Switch grid’s column widths to fixed instead of fluid |
71
73
|`.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. |
73
74
|`.bootstrap-padding`| Add one unit of padding to element on all sides |
74
75
|`.bootstrap-padding--[bottom, left, right, top]`| Add one unit of padding to element on one side |
75
76
|`.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).
|`.bootstrap-grid__col--sm--[1-12]`| Set the width out of 12 columns for an item in the grid starting at the sm breakpoint |
88
78
|`.bootstrap-grid__col--[sm]--0`| Do not display item at a specific breakpoint, but display at the next breakpoint with columns specified |
89
79
|`.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 |
92
81
|`.bootstrap-grid__height--[sm]--0`| Reset the min-height for an item starting at the specified breakpoint |
93
82
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.
95
84
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.
97
86
98
87
## Variables
99
88
@@ -120,6 +109,77 @@ We provide the fixed height variables for items that are not direct children of
120
109
}
121
110
```
122
111
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
+
@includemedia-query('sm') {
122
+
border: 2pxsolidhotpink;
123
+
}
124
+
}
125
+
```
126
+
127
+
**Output CSS**
128
+
```css
129
+
@mediascreenand (min-width: 20rem) {
130
+
button {
131
+
border: 2pxsolidhotpink;
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
+
@mediascreenand (min-width: 20rem) {
145
+
button {
146
+
@includemedia-query('sm') {
147
+
max-width: get-fluid-size('sm', 1);
148
+
}
149
+
}
150
+
}
151
+
```
152
+
153
+
**Output CSS**
154
+
```css
155
+
@mediascreenand (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
+
@includemedia-query('sm') {
169
+
max-width: get-fixed-size(10);
170
+
}
171
+
}
172
+
```
173
+
174
+
**Output CSS**
175
+
```css
176
+
@mediascreenand (min-width: 20rem) {
177
+
button {
178
+
max-width: 5rem;
179
+
}
180
+
}
181
+
```
182
+
123
183
## FAQs
124
184
125
185
### 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
138
198
able to take advantage of vw units and the calc function so you can embed
139
199
`.bootstrap-grid` elements inside of each other and still respect the overall grid design.
140
200
141
-
### Why are there no row classes for the legacy implementation?
201
+
### Why are there no grouping row classes needed?
142
202
143
203
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.
0 commit comments