1 |
efrain |
1 |
---
|
|
|
2 |
layout: docs
|
|
|
3 |
title: Flex
|
|
|
4 |
description: Quickly manage the layout, alignment, and sizing of grid columns, navigation, components, and more with a full suite of responsive flexbox utilities. For more complex implementations, custom CSS may be necessary.
|
|
|
5 |
group: utilities
|
|
|
6 |
toc: true
|
|
|
7 |
---
|
|
|
8 |
|
|
|
9 |
## Enable flex behaviors
|
|
|
10 |
|
|
|
11 |
Apply `display` utilities to create a flexbox container and transform **direct children elements** into flex items. Flex containers and items are able to be modified further with additional flex properties.
|
|
|
12 |
|
|
|
13 |
{{< example >}}
|
|
|
14 |
<div class="d-flex p-2 bd-highlight">I'm a flexbox container!</div>
|
|
|
15 |
{{< /example >}}
|
|
|
16 |
|
|
|
17 |
{{< example >}}
|
|
|
18 |
<div class="d-inline-flex p-2 bd-highlight">I'm an inline flexbox container!</div>
|
|
|
19 |
{{< /example >}}
|
|
|
20 |
|
|
|
21 |
Responsive variations also exist for `.d-flex` and `.d-inline-flex`.
|
|
|
22 |
|
|
|
23 |
{{< markdown >}}
|
|
|
24 |
{{< flex.inline >}}
|
|
|
25 |
{{- range $.Site.Data.breakpoints }}
|
|
|
26 |
- `.d{{ .abbr }}-flex`
|
|
|
27 |
- `.d{{ .abbr }}-inline-flex`
|
|
|
28 |
{{- end -}}
|
|
|
29 |
{{< /flex.inline >}}
|
|
|
30 |
{{< /markdown >}}
|
|
|
31 |
|
|
|
32 |
## Direction
|
|
|
33 |
|
|
|
34 |
Set the direction of flex items in a flex container with direction utilities. In most cases you can omit the horizontal class here as the browser default is `row`. However, you may encounter situations where you needed to explicitly set this value (like responsive layouts).
|
|
|
35 |
|
|
|
36 |
Use `.flex-row` to set a horizontal direction (the browser default), or `.flex-row-reverse` to start the horizontal direction from the opposite side.
|
|
|
37 |
|
|
|
38 |
{{< example >}}
|
|
|
39 |
<div class="d-flex flex-row bd-highlight mb-3">
|
|
|
40 |
<div class="p-2 bd-highlight">Flex item 1</div>
|
|
|
41 |
<div class="p-2 bd-highlight">Flex item 2</div>
|
|
|
42 |
<div class="p-2 bd-highlight">Flex item 3</div>
|
|
|
43 |
</div>
|
|
|
44 |
<div class="d-flex flex-row-reverse bd-highlight">
|
|
|
45 |
<div class="p-2 bd-highlight">Flex item 1</div>
|
|
|
46 |
<div class="p-2 bd-highlight">Flex item 2</div>
|
|
|
47 |
<div class="p-2 bd-highlight">Flex item 3</div>
|
|
|
48 |
</div>
|
|
|
49 |
{{< /example >}}
|
|
|
50 |
|
|
|
51 |
Use `.flex-column` to set a vertical direction, or `.flex-column-reverse` to start the vertical direction from the opposite side.
|
|
|
52 |
|
|
|
53 |
{{< example >}}
|
|
|
54 |
<div class="d-flex flex-column bd-highlight mb-3">
|
|
|
55 |
<div class="p-2 bd-highlight">Flex item 1</div>
|
|
|
56 |
<div class="p-2 bd-highlight">Flex item 2</div>
|
|
|
57 |
<div class="p-2 bd-highlight">Flex item 3</div>
|
|
|
58 |
</div>
|
|
|
59 |
<div class="d-flex flex-column-reverse bd-highlight">
|
|
|
60 |
<div class="p-2 bd-highlight">Flex item 1</div>
|
|
|
61 |
<div class="p-2 bd-highlight">Flex item 2</div>
|
|
|
62 |
<div class="p-2 bd-highlight">Flex item 3</div>
|
|
|
63 |
</div>
|
|
|
64 |
{{< /example >}}
|
|
|
65 |
|
|
|
66 |
Responsive variations also exist for `flex-direction`.
|
|
|
67 |
|
|
|
68 |
{{< markdown >}}
|
|
|
69 |
{{< flex.inline >}}
|
|
|
70 |
{{- range $.Site.Data.breakpoints }}
|
|
|
71 |
- `.flex{{ .abbr }}-row`
|
|
|
72 |
- `.flex{{ .abbr }}-row-reverse`
|
|
|
73 |
- `.flex{{ .abbr }}-column`
|
|
|
74 |
- `.flex{{ .abbr }}-column-reverse`
|
|
|
75 |
{{- end -}}
|
|
|
76 |
{{< /flex.inline >}}
|
|
|
77 |
{{< /markdown >}}
|
|
|
78 |
|
|
|
79 |
## Justify content
|
|
|
80 |
|
|
|
81 |
Use `justify-content` utilities on flexbox containers to change the alignment of flex items on the main axis (the x-axis to start, y-axis if `flex-direction: column`). Choose from `start` (browser default), `end`, `center`, `between`, or `around`.
|
|
|
82 |
|
|
|
83 |
<div class="bd-example">
|
|
|
84 |
<div class="d-flex justify-content-start bd-highlight mb-3">
|
|
|
85 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
86 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
87 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
88 |
</div>
|
|
|
89 |
<div class="d-flex justify-content-end bd-highlight mb-3">
|
|
|
90 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
91 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
92 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
93 |
</div>
|
|
|
94 |
<div class="d-flex justify-content-center bd-highlight mb-3">
|
|
|
95 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
96 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
97 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
98 |
</div>
|
|
|
99 |
<div class="d-flex justify-content-between bd-highlight mb-3">
|
|
|
100 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
101 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
102 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
103 |
</div>
|
|
|
104 |
<div class="d-flex justify-content-around bd-highlight">
|
|
|
105 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
106 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
107 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
108 |
</div>
|
|
|
109 |
</div>
|
|
|
110 |
|
|
|
111 |
```html
|
|
|
112 |
<div class="d-flex justify-content-start">...</div>
|
|
|
113 |
<div class="d-flex justify-content-end">...</div>
|
|
|
114 |
<div class="d-flex justify-content-center">...</div>
|
|
|
115 |
<div class="d-flex justify-content-between">...</div>
|
|
|
116 |
<div class="d-flex justify-content-around">...</div>
|
|
|
117 |
```
|
|
|
118 |
|
|
|
119 |
Responsive variations also exist for `justify-content`.
|
|
|
120 |
|
|
|
121 |
{{< markdown >}}
|
|
|
122 |
{{< flex.inline >}}
|
|
|
123 |
{{- range $.Site.Data.breakpoints }}
|
|
|
124 |
- `.justify-content{{ .abbr }}-start`
|
|
|
125 |
- `.justify-content{{ .abbr }}-end`
|
|
|
126 |
- `.justify-content{{ .abbr }}-center`
|
|
|
127 |
- `.justify-content{{ .abbr }}-between`
|
|
|
128 |
- `.justify-content{{ .abbr }}-around`
|
|
|
129 |
{{- end -}}
|
|
|
130 |
{{< /flex.inline >}}
|
|
|
131 |
{{< /markdown >}}
|
|
|
132 |
|
|
|
133 |
## Align items
|
|
|
134 |
|
|
|
135 |
Use `align-items` utilities on flexbox containers to change the alignment of flex items on the cross axis (the y-axis to start, x-axis if `flex-direction: column`). Choose from `start`, `end`, `center`, `baseline`, or `stretch` (browser default).
|
|
|
136 |
|
|
|
137 |
<div class="bd-example">
|
|
|
138 |
<div class="d-flex align-items-start bd-highlight mb-3" style="height: 100px">
|
|
|
139 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
140 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
141 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
142 |
</div>
|
|
|
143 |
<div class="d-flex align-items-end bd-highlight mb-3" style="height: 100px">
|
|
|
144 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
145 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
146 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
147 |
</div>
|
|
|
148 |
<div class="d-flex align-items-center bd-highlight mb-3" style="height: 100px">
|
|
|
149 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
150 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
151 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
152 |
</div>
|
|
|
153 |
<div class="d-flex align-items-baseline bd-highlight mb-3" style="height: 100px">
|
|
|
154 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
155 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
156 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
157 |
</div>
|
|
|
158 |
<div class="d-flex align-items-stretch bd-highlight" style="height: 100px">
|
|
|
159 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
160 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
161 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
162 |
</div>
|
|
|
163 |
</div>
|
|
|
164 |
|
|
|
165 |
```html
|
|
|
166 |
<div class="d-flex align-items-start">...</div>
|
|
|
167 |
<div class="d-flex align-items-end">...</div>
|
|
|
168 |
<div class="d-flex align-items-center">...</div>
|
|
|
169 |
<div class="d-flex align-items-baseline">...</div>
|
|
|
170 |
<div class="d-flex align-items-stretch">...</div>
|
|
|
171 |
```
|
|
|
172 |
|
|
|
173 |
Responsive variations also exist for `align-items`.
|
|
|
174 |
|
|
|
175 |
{{< markdown >}}
|
|
|
176 |
{{< flex.inline >}}
|
|
|
177 |
{{- range $.Site.Data.breakpoints }}
|
|
|
178 |
- `.align-items{{ .abbr }}-start`
|
|
|
179 |
- `.align-items{{ .abbr }}-end`
|
|
|
180 |
- `.align-items{{ .abbr }}-center`
|
|
|
181 |
- `.align-items{{ .abbr }}-baseline`
|
|
|
182 |
- `.align-items{{ .abbr }}-stretch`
|
|
|
183 |
{{- end -}}
|
|
|
184 |
{{< /flex.inline >}}
|
|
|
185 |
{{< /markdown >}}
|
|
|
186 |
|
|
|
187 |
## Align self
|
|
|
188 |
|
|
|
189 |
Use `align-self` utilities on flexbox items to individually change their alignment on the cross axis (the y-axis to start, x-axis if `flex-direction: column`). Choose from the same options as `align-items`: `start`, `end`, `center`, `baseline`, or `stretch` (browser default).
|
|
|
190 |
|
|
|
191 |
<div class="bd-example">
|
|
|
192 |
<div class="d-flex bd-highlight mb-3" style="height: 100px">
|
|
|
193 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
194 |
<div class="align-self-start p-2 bd-highlight">Aligned flex item</div>
|
|
|
195 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
196 |
</div>
|
|
|
197 |
<div class="d-flex bd-highlight mb-3" style="height: 100px">
|
|
|
198 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
199 |
<div class="align-self-end p-2 bd-highlight">Aligned flex item</div>
|
|
|
200 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
201 |
</div>
|
|
|
202 |
<div class="d-flex bd-highlight mb-3" style="height: 100px">
|
|
|
203 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
204 |
<div class="align-self-center p-2 bd-highlight">Aligned flex item</div>
|
|
|
205 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
206 |
</div>
|
|
|
207 |
<div class="d-flex bd-highlight mb-3" style="height: 100px">
|
|
|
208 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
209 |
<div class="align-self-baseline p-2 bd-highlight">Aligned flex item</div>
|
|
|
210 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
211 |
</div>
|
|
|
212 |
<div class="d-flex bd-highlight" style="height: 100px">
|
|
|
213 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
214 |
<div class="align-self-stretch p-2 bd-highlight">Aligned flex item</div>
|
|
|
215 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
216 |
</div>
|
|
|
217 |
</div>
|
|
|
218 |
|
|
|
219 |
```html
|
|
|
220 |
<div class="align-self-start">Aligned flex item</div>
|
|
|
221 |
<div class="align-self-end">Aligned flex item</div>
|
|
|
222 |
<div class="align-self-center">Aligned flex item</div>
|
|
|
223 |
<div class="align-self-baseline">Aligned flex item</div>
|
|
|
224 |
<div class="align-self-stretch">Aligned flex item</div>
|
|
|
225 |
```
|
|
|
226 |
|
|
|
227 |
Responsive variations also exist for `align-self`.
|
|
|
228 |
|
|
|
229 |
{{< markdown >}}
|
|
|
230 |
{{< flex.inline >}}
|
|
|
231 |
{{- range $.Site.Data.breakpoints }}
|
|
|
232 |
- `.align-self{{ .abbr }}-start`
|
|
|
233 |
- `.align-self{{ .abbr }}-end`
|
|
|
234 |
- `.align-self{{ .abbr }}-center`
|
|
|
235 |
- `.align-self{{ .abbr }}-baseline`
|
|
|
236 |
- `.align-self{{ .abbr }}-stretch`
|
|
|
237 |
{{- end -}}
|
|
|
238 |
{{< /flex.inline >}}
|
|
|
239 |
{{< /markdown >}}
|
|
|
240 |
|
|
|
241 |
## Fill
|
|
|
242 |
|
|
|
243 |
Use the `.flex-fill` class on a series of sibling elements to force them into widths equal to their content (or equal widths if their content does not surpass their border-boxes) while taking up all available horizontal space.
|
|
|
244 |
|
|
|
245 |
{{< example >}}
|
|
|
246 |
<div class="d-flex bd-highlight">
|
|
|
247 |
<div class="p-2 flex-fill bd-highlight">Flex item with a lot of content</div>
|
|
|
248 |
<div class="p-2 flex-fill bd-highlight">Flex item</div>
|
|
|
249 |
<div class="p-2 flex-fill bd-highlight">Flex item</div>
|
|
|
250 |
</div>
|
|
|
251 |
{{< /example >}}
|
|
|
252 |
|
|
|
253 |
Responsive variations also exist for `flex-fill`.
|
|
|
254 |
|
|
|
255 |
{{< markdown >}}
|
|
|
256 |
{{< flex.inline >}}
|
|
|
257 |
{{- range $.Site.Data.breakpoints }}
|
|
|
258 |
- `.flex{{ .abbr }}-fill`
|
|
|
259 |
{{- end -}}
|
|
|
260 |
{{< /flex.inline >}}
|
|
|
261 |
{{< /markdown >}}
|
|
|
262 |
|
|
|
263 |
## Grow and shrink
|
|
|
264 |
|
|
|
265 |
Use `.flex-grow-*` utilities to toggle a flex item's ability to grow to fill available space. In the example below, the `.flex-grow-1` elements uses all available space it can, while allowing the remaining two flex items their necessary space.
|
|
|
266 |
|
|
|
267 |
{{< example >}}
|
|
|
268 |
<div class="d-flex bd-highlight">
|
|
|
269 |
<div class="p-2 flex-grow-1 bd-highlight">Flex item</div>
|
|
|
270 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
271 |
<div class="p-2 bd-highlight">Third flex item</div>
|
|
|
272 |
</div>
|
|
|
273 |
{{< /example >}}
|
|
|
274 |
|
|
|
275 |
Use `.flex-shrink-*` utilities to toggle a flex item's ability to shrink if necessary. In the example below, the second flex item with `.flex-shrink-1` is forced to wrap its contents to a new line, "shrinking" to allow more space for the previous flex item with `.w-100`.
|
|
|
276 |
|
|
|
277 |
{{< example >}}
|
|
|
278 |
<div class="d-flex bd-highlight">
|
|
|
279 |
<div class="p-2 w-100 bd-highlight">Flex item</div>
|
|
|
280 |
<div class="p-2 flex-shrink-1 bd-highlight">Flex item</div>
|
|
|
281 |
</div>
|
|
|
282 |
{{< /example >}}
|
|
|
283 |
|
|
|
284 |
Responsive variations also exist for `flex-grow` and `flex-shrink`.
|
|
|
285 |
|
|
|
286 |
{{< markdown >}}
|
|
|
287 |
{{< flex.inline >}}
|
|
|
288 |
{{- range $.Site.Data.breakpoints }}
|
|
|
289 |
- `.flex{{ .abbr }}-{grow|shrink}-0`
|
|
|
290 |
- `.flex{{ .abbr }}-{grow|shrink}-1`
|
|
|
291 |
{{- end -}}
|
|
|
292 |
{{< /flex.inline >}}
|
|
|
293 |
{{< /markdown >}}
|
|
|
294 |
|
|
|
295 |
## Auto margins
|
|
|
296 |
|
|
|
297 |
Flexbox can do some pretty awesome things when you mix flex alignments with auto margins. Shown below are three examples of controlling flex items via auto margins: default (no auto margin), pushing two items to the right (`.mr-auto`), and pushing two items to the left (`.ml-auto`).
|
|
|
298 |
|
|
|
299 |
**Unfortunately, IE10 and IE11 do not properly support auto margins on flex items whose parent has a non-default `justify-content` value.** [See this StackOverflow answer](https://stackoverflow.com/a/37535548) for more details.
|
|
|
300 |
|
|
|
301 |
{{< example >}}
|
|
|
302 |
<div class="d-flex bd-highlight mb-3">
|
|
|
303 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
304 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
305 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
306 |
</div>
|
|
|
307 |
|
|
|
308 |
<div class="d-flex bd-highlight mb-3">
|
|
|
309 |
<div class="mr-auto p-2 bd-highlight">Flex item</div>
|
|
|
310 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
311 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
312 |
</div>
|
|
|
313 |
|
|
|
314 |
<div class="d-flex bd-highlight mb-3">
|
|
|
315 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
316 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
317 |
<div class="ml-auto p-2 bd-highlight">Flex item</div>
|
|
|
318 |
</div>
|
|
|
319 |
{{< /example >}}
|
|
|
320 |
|
|
|
321 |
### With align-items
|
|
|
322 |
|
|
|
323 |
Vertically move one flex item to the top or bottom of a container by mixing `align-items`, `flex-direction: column`, and `margin-top: auto` or `margin-bottom: auto`.
|
|
|
324 |
|
|
|
325 |
{{< example >}}
|
|
|
326 |
<div class="d-flex align-items-start flex-column bd-highlight mb-3" style="height: 200px;">
|
|
|
327 |
<div class="mb-auto p-2 bd-highlight">Flex item</div>
|
|
|
328 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
329 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
330 |
</div>
|
|
|
331 |
|
|
|
332 |
<div class="d-flex align-items-end flex-column bd-highlight mb-3" style="height: 200px;">
|
|
|
333 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
334 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
335 |
<div class="mt-auto p-2 bd-highlight">Flex item</div>
|
|
|
336 |
</div>
|
|
|
337 |
{{< /example >}}
|
|
|
338 |
|
|
|
339 |
## Wrap
|
|
|
340 |
|
|
|
341 |
Change how flex items wrap in a flex container. Choose from no wrapping at all (the browser default) with `.flex-nowrap`, wrapping with `.flex-wrap`, or reverse wrapping with `.flex-wrap-reverse`.
|
|
|
342 |
|
|
|
343 |
<div class="bd-example">
|
|
|
344 |
<div class="d-flex flex-nowrap bd-highlight" style="width: 8rem;">
|
|
|
345 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
346 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
347 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
348 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
349 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
350 |
</div>
|
|
|
351 |
</div>
|
|
|
352 |
|
|
|
353 |
```html
|
|
|
354 |
<div class="d-flex flex-nowrap">
|
|
|
355 |
...
|
|
|
356 |
</div>
|
|
|
357 |
```
|
|
|
358 |
|
|
|
359 |
<div class="bd-example">
|
|
|
360 |
<div class="d-flex flex-wrap bd-highlight">
|
|
|
361 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
362 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
363 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
364 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
365 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
366 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
367 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
368 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
369 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
370 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
371 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
372 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
373 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
374 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
375 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
376 |
</div>
|
|
|
377 |
</div>
|
|
|
378 |
|
|
|
379 |
```html
|
|
|
380 |
<div class="d-flex flex-wrap">
|
|
|
381 |
...
|
|
|
382 |
</div>
|
|
|
383 |
```
|
|
|
384 |
|
|
|
385 |
<div class="bd-example">
|
|
|
386 |
<div class="d-flex flex-wrap-reverse bd-highlight">
|
|
|
387 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
388 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
389 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
390 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
391 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
392 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
393 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
394 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
395 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
396 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
397 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
398 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
399 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
400 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
401 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
402 |
</div>
|
|
|
403 |
</div>
|
|
|
404 |
|
|
|
405 |
```html
|
|
|
406 |
<div class="d-flex flex-wrap-reverse">
|
|
|
407 |
...
|
|
|
408 |
</div>
|
|
|
409 |
```
|
|
|
410 |
|
|
|
411 |
|
|
|
412 |
Responsive variations also exist for `flex-wrap`.
|
|
|
413 |
|
|
|
414 |
{{< markdown >}}
|
|
|
415 |
{{< flex.inline >}}
|
|
|
416 |
{{- range $.Site.Data.breakpoints }}
|
|
|
417 |
- `.flex{{ .abbr }}-nowrap`
|
|
|
418 |
- `.flex{{ .abbr }}-wrap`
|
|
|
419 |
- `.flex{{ .abbr }}-wrap-reverse`
|
|
|
420 |
{{- end -}}
|
|
|
421 |
{{< /flex.inline >}}
|
|
|
422 |
{{< /markdown >}}
|
|
|
423 |
|
|
|
424 |
## Order
|
|
|
425 |
|
|
|
426 |
Change the _visual_ order of specific flex items with a handful of `order` utilities. We only provide options for making an item first or last, as well as a reset to use the DOM order. As `order` takes any integer value (e.g., `5`), add custom CSS for any additional values needed.
|
|
|
427 |
|
|
|
428 |
{{< example >}}
|
|
|
429 |
<div class="d-flex flex-nowrap bd-highlight">
|
|
|
430 |
<div class="order-3 p-2 bd-highlight">First flex item</div>
|
|
|
431 |
<div class="order-2 p-2 bd-highlight">Second flex item</div>
|
|
|
432 |
<div class="order-1 p-2 bd-highlight">Third flex item</div>
|
|
|
433 |
</div>
|
|
|
434 |
{{< /example >}}
|
|
|
435 |
|
|
|
436 |
Responsive variations also exist for `order`.
|
|
|
437 |
|
|
|
438 |
{{< markdown >}}
|
|
|
439 |
{{< flex.inline >}}
|
|
|
440 |
{{- range $bp := $.Site.Data.breakpoints -}}
|
|
|
441 |
{{- range (seq 0 12) }}
|
|
|
442 |
- `.order{{ $bp.abbr }}-{{ . }}`
|
|
|
443 |
{{- end -}}
|
|
|
444 |
{{- end -}}
|
|
|
445 |
{{< /flex.inline >}}
|
|
|
446 |
{{< /markdown >}}
|
|
|
447 |
|
|
|
448 |
|
|
|
449 |
## Align content
|
|
|
450 |
|
|
|
451 |
Use `align-content` utilities on flexbox containers to align flex items *together* on the cross axis. Choose from `start` (browser default), `end`, `center`, `between`, `around`, or `stretch`. To demonstrate these utilities, we've enforced `flex-wrap: wrap` and increased the number of flex items.
|
|
|
452 |
|
|
|
453 |
**Heads up!** This property has no effect on single rows of flex items.
|
|
|
454 |
|
|
|
455 |
<div class="bd-example">
|
|
|
456 |
<div class="d-flex align-content-start flex-wrap bd-highlight mb-3" style="height: 200px">
|
|
|
457 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
458 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
459 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
460 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
461 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
462 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
463 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
464 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
465 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
466 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
467 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
468 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
469 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
470 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
471 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
472 |
</div>
|
|
|
473 |
</div>
|
|
|
474 |
|
|
|
475 |
```html
|
|
|
476 |
<div class="d-flex align-content-start flex-wrap">
|
|
|
477 |
...
|
|
|
478 |
</div>
|
|
|
479 |
```
|
|
|
480 |
|
|
|
481 |
<div class="bd-example">
|
|
|
482 |
<div class="d-flex align-content-end flex-wrap bd-highlight mb-3" style="height: 200px">
|
|
|
483 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
484 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
485 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
486 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
487 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
488 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
489 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
490 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
491 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
492 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
493 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
494 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
495 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
496 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
497 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
498 |
</div>
|
|
|
499 |
</div>
|
|
|
500 |
|
|
|
501 |
```html
|
|
|
502 |
<div class="d-flex align-content-end flex-wrap">...</div>
|
|
|
503 |
```
|
|
|
504 |
|
|
|
505 |
<div class="bd-example">
|
|
|
506 |
<div class="d-flex align-content-center flex-wrap bd-highlight mb-3" style="height: 200px">
|
|
|
507 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
508 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
509 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
510 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
511 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
512 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
513 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
514 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
515 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
516 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
517 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
518 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
519 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
520 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
521 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
522 |
</div>
|
|
|
523 |
</div>
|
|
|
524 |
|
|
|
525 |
```html
|
|
|
526 |
<div class="d-flex align-content-center flex-wrap">...</div>
|
|
|
527 |
```
|
|
|
528 |
|
|
|
529 |
<div class="bd-example">
|
|
|
530 |
<div class="d-flex align-content-between flex-wrap bd-highlight mb-3" style="height: 200px">
|
|
|
531 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
532 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
533 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
534 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
535 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
536 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
537 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
538 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
539 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
540 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
541 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
542 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
543 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
544 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
545 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
546 |
</div>
|
|
|
547 |
</div>
|
|
|
548 |
|
|
|
549 |
```html
|
|
|
550 |
<div class="d-flex align-content-between flex-wrap">...</div>
|
|
|
551 |
```
|
|
|
552 |
|
|
|
553 |
<div class="bd-example">
|
|
|
554 |
<div class="d-flex align-content-around flex-wrap bd-highlight mb-3" style="height: 200px">
|
|
|
555 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
556 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
557 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
558 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
559 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
560 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
561 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
562 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
563 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
564 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
565 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
566 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
567 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
568 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
569 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
570 |
</div>
|
|
|
571 |
</div>
|
|
|
572 |
|
|
|
573 |
```html
|
|
|
574 |
<div class="d-flex align-content-around flex-wrap">...</div>
|
|
|
575 |
```
|
|
|
576 |
|
|
|
577 |
<div class="bd-example">
|
|
|
578 |
<div class="d-flex align-content-stretch flex-wrap bd-highlight mb-3" style="height: 200px">
|
|
|
579 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
580 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
581 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
582 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
583 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
584 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
585 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
586 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
587 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
588 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
589 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
590 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
591 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
592 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
593 |
<div class="p-2 bd-highlight">Flex item</div>
|
|
|
594 |
</div>
|
|
|
595 |
</div>
|
|
|
596 |
|
|
|
597 |
```html
|
|
|
598 |
<div class="d-flex align-content-stretch flex-wrap">...</div>
|
|
|
599 |
```
|
|
|
600 |
|
|
|
601 |
Responsive variations also exist for `align-content`.
|
|
|
602 |
|
|
|
603 |
{{< markdown >}}
|
|
|
604 |
{{< flex.inline >}}
|
|
|
605 |
{{- range $.Site.Data.breakpoints }}
|
|
|
606 |
- `.align-content{{ .abbr }}-start`
|
|
|
607 |
- `.align-content{{ .abbr }}-end`
|
|
|
608 |
- `.align-content{{ .abbr }}-center`
|
|
|
609 |
- `.align-content{{ .abbr }}-between`
|
|
|
610 |
- `.align-content{{ .abbr }}-around`
|
|
|
611 |
- `.align-content{{ .abbr }}-stretch`
|
|
|
612 |
{{- end -}}
|
|
|
613 |
{{< /flex.inline >}}
|
|
|
614 |
{{< /markdown >}}
|