1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-31 00:59:51 +02:00

Docs: quick fixes for HTML (#36395)

* Using the new helper in the doc

* Remove input from `Tab` access

* Change scrollspy code examples

* Reordering tables for JS

* Fix for parcel file

* Center align all the code example texts in layout

* Alphabetical reorder the helpers
This commit is contained in:
Louis-Maxime Piton
2022-05-20 19:21:48 +02:00
committed by GitHub
parent 73e45ee36c
commit 8959bf3f0b
36 changed files with 276 additions and 262 deletions

View File

@@ -25,7 +25,7 @@ Use flexbox alignment utilities to vertically and horizontally align columns.
### Vertical alignment
{{< example class="bd-example-row bd-example-row-flex-cols" >}}
<div class="container">
<div class="container text-center">
<div class="row align-items-start">
<div class="col">
One of three columns
@@ -63,7 +63,7 @@ Use flexbox alignment utilities to vertically and horizontally align columns.
{{< /example >}}
{{< example class="bd-example-row bd-example-row-flex-cols" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col align-self-start">
One of three columns
@@ -81,7 +81,7 @@ Use flexbox alignment utilities to vertically and horizontally align columns.
### Horizontal alignment
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row justify-content-start">
<div class="col-4">
One of two columns
@@ -152,7 +152,7 @@ If more than 12 columns are placed within a single row, each group of extra colu
Breaking columns to a new line in flexbox requires a small hack: add an element with `width: 100%` wherever you want to wrap your columns to a new line. Normally this is accomplished with multiple `.row`s, but not every implementation method can account for this.
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
@@ -169,7 +169,7 @@ Breaking columns to a new line in flexbox requires a small hack: add an element
You may also apply this break at specific breakpoints with our [responsive display utilities]({{< docsref "/utilities/display" >}}).
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
@@ -190,7 +190,7 @@ You may also apply this break at specific breakpoints with our [responsive displ
Use `.order-` classes for controlling the **visual order** of your content. These classes are responsive, so you can set the `order` by breakpoint (e.g., `.order-1.order-md-2`). Includes support for `1` through `5` across all six grid tiers.
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col">
First in DOM, no order applied
@@ -208,7 +208,7 @@ Use `.order-` classes for controlling the **visual order** of your content. Thes
There are also responsive `.order-first` and `.order-last` classes that change the `order` of an element by applying `order: -1` and `order: 6`, respectively. These classes can also be intermixed with the numbered `.order-*` classes as needed.
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col order-last">
First in DOM, ordered last
@@ -232,7 +232,7 @@ You can offset grid columns in two ways: our responsive `.offset-` grid classes
Move columns to the right using `.offset-md-*` classes. These classes increase the left margin of a column by `*` columns. For example, `.offset-md-4` moves `.col-md-4` over four columns.
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4 offset-md-4">.col-md-4 .offset-md-4</div>
@@ -250,7 +250,7 @@ Move columns to the right using `.offset-md-*` classes. These classes increase t
In addition to column clearing at responsive breakpoints, you may need to reset offsets. See this in action in [the grid example]({{< docsref "/examples/grid" >}}).
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
<div class="col-sm-5 offset-sm-2 col-md-6 offset-md-0">.col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0</div>
@@ -267,7 +267,7 @@ In addition to column clearing at responsive breakpoints, you may need to reset
With the move to flexbox in v4, you can use margin utilities like `.me-auto` to force sibling columns away from one another.
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4 ms-auto">.col-md-4 .ms-auto</div>

View File

@@ -47,8 +47,8 @@ Compared to the default grid system:
Three equal-width columns across all viewports and devices can be created by using the `.g-col-4` classes. Add [responsive classes](#responsive) to change the layout by viewport size.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center">
<div class="g-col-4">.g-col-4</div>
<div class="g-col-4">.g-col-4</div>
<div class="g-col-4">.g-col-4</div>
@@ -59,8 +59,8 @@ Three equal-width columns across all viewports and devices can be created by usi
Use responsive classes to adjust your layout across viewports. Here we start with two columns on the narrowest viewports, and then grow to three columns on medium viewports and above.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center">
<div class="g-col-6 g-col-md-4">.g-col-6 .g-col-md-4</div>
<div class="g-col-6 g-col-md-4">.g-col-6 .g-col-md-4</div>
<div class="g-col-6 g-col-md-4">.g-col-6 .g-col-md-4</div>
@@ -69,8 +69,8 @@ Use responsive classes to adjust your layout across viewports. Here we start wit
Compare that to this two column layout at all viewports.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center">
<div class="g-col-6">.g-col-6</div>
<div class="g-col-6">.g-col-6</div>
</div>
@@ -80,8 +80,8 @@ Compare that to this two column layout at all viewports.
Grid items automatically wrap to the next line when there's no more room horizontally. Note that the `gap` applies to horizontal and vertical gaps between grid items.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center">
<div class="g-col-6">.g-col-6</div>
<div class="g-col-6">.g-col-6</div>
@@ -94,8 +94,8 @@ Grid items automatically wrap to the next line when there's no more room horizon
Start classes aim to replace our default grid's offset classes, but they're not entirely the same. CSS Grid creates a grid template through styles that tell browsers to "start at this column" and "end at this column." Those properties are `grid-column-start` and `grid-column-end`. Start classes are shorthand for the former. Pair them with the column classes to size and align your columns however you need. Start classes begin at `1` as `0` is an invalid value for these properties.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center">
<div class="g-col-3 g-start-2">.g-col-3 .g-start-2</div>
<div class="g-col-4 g-start-6">.g-col-4 .g-start-6</div>
</div>
@@ -105,8 +105,8 @@ Start classes aim to replace our default grid's offset classes, but they're not
When there are no classes on the grid items (the immediate children of a `.grid`), each grid item will automatically be sized to one column.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center">
<div>1</div>
<div>1</div>
<div>1</div>
@@ -124,8 +124,8 @@ When there are no classes on the grid items (the immediate children of a `.grid`
This behavior can be mixed with grid column classes.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center">
<div class="g-col-6">.g-col-6</div>
<div>1</div>
<div>1</div>
@@ -147,8 +147,8 @@ Similar to our default grid system, our CSS Grid allows for easy nesting of `.gr
In practice this allows for more complex and custom layouts when compared to our default grid system.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid" style="--bs-columns: 3;">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center" style="--bs-columns: 3;">
<div>
First auto-column
<div class="grid">
@@ -186,8 +186,8 @@ These CSS variables have no default value; instead, they apply fallback values t
Immediate children elements of `.grid` are grid items, so they'll be sized without explicitly adding a `.g-col` class.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid" style="--bs-columns: 3;">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center" style="--bs-columns: 3;">
<div>Auto-column</div>
<div>Auto-column</div>
<div>Auto-column</div>
@@ -198,15 +198,15 @@ Immediate children elements of `.grid` are grid items, so they'll be sized witho
Adjust the number of columns and the gap.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid" style="--bs-columns: 4; --bs-gap: 5rem;">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center" style="--bs-columns: 4; --bs-gap: 5rem;">
<div class="g-col-2">.g-col-2</div>
<div class="g-col-2">.g-col-2</div>
</div>
{{< /example >}}
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid" style="--bs-columns: 10; --bs-gap: 1rem;">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center" style="--bs-columns: 10; --bs-gap: 1rem;">
<div class="g-col-6">.g-col-6</div>
<div class="g-col-4">.g-col-4</div>
</div>
@@ -216,8 +216,8 @@ Adjust the number of columns and the gap.
Adding more rows and changing the placement of columns:
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid" style="--bs-rows: 3; --bs-columns: 3;">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center" style="--bs-rows: 3; --bs-columns: 3;">
<div>Auto-column</div>
<div class="g-start-2" style="grid-row: 2">Auto-column</div>
<div class="g-start-3" style="grid-row: 3">Auto-column</div>
@@ -228,8 +228,8 @@ Adding more rows and changing the placement of columns:
Change the vertical gaps only by modifying the `row-gap`. Note that we use `gap` on `.grid`s, but `row-gap` and `column-gap` can be modified as needed.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid" style="row-gap: 0;">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center" style="row-gap: 0;">
<div class="g-col-6">.g-col-6</div>
<div class="g-col-6">.g-col-6</div>
@@ -240,8 +240,8 @@ Change the vertical gaps only by modifying the `row-gap`. Note that we use `gap`
Because of that, you can have different vertical and horizontal `gap`s, which can take a single value (all sides) or a pair of values (vertical and horizontal). This can be applied with an inline style for `gap`, or with our `--bs-gap` CSS variable.
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid" style="--bs-gap: .25rem 1rem;">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center" style="--bs-gap: .25rem 1rem;">
<div class="g-col-6">.g-col-6</div>
<div class="g-col-6">.g-col-6</div>
@@ -259,8 +259,8 @@ One limitation of the CSS Grid is that our default classes are still generated b
For example, you can increase the column count and change the gap size, and then size your "columns" with a mix of inline styles and predefined CSS Grid column classes (e.g., `.g-col-4`).
{{< example class="bd-example-cssgrid text-center" >}}
<div class="grid" style="--bs-columns: 18; --bs-gap: .5rem;">
{{< example class="bd-example-cssgrid" >}}
<div class="grid text-center" style="--bs-columns: 18; --bs-gap: .5rem;">
<div style="grid-column: span 14;">14 columns</div>
<div class="g-col-4">.g-col-4</div>
</div>

View File

@@ -15,7 +15,7 @@ Bootstrap's grid system uses a series of containers, rows, and columns to layout
{{< /callout >}}
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col">
Column
@@ -144,7 +144,7 @@ Utilize breakpoint-specific column classes for easy column sizing without an exp
For example, here are two grid layouts that apply to every device and viewport, from `xs` to `xxl`. Add any number of unit-less classes for each breakpoint you need and every column will be the same width.
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col">
1 of 2
@@ -172,7 +172,7 @@ For example, here are two grid layouts that apply to every device and viewport,
Auto-layout for flexbox grid columns also means you can set the width of one column and have the sibling columns automatically resize around it. You may use predefined grid classes (as shown below), grid mixins, or inline widths. Note that the other columns will resize no matter the width of the center column.
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col">
1 of 3
@@ -203,7 +203,7 @@ Auto-layout for flexbox grid columns also means you can set the width of one col
Use `col-{breakpoint}-auto` classes to size columns based on the natural width of their content.
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row justify-content-md-center">
<div class="col col-lg-2">
1 of 3
@@ -238,7 +238,7 @@ Bootstrap's grid includes six tiers of predefined classes for building complex r
For grids that are the same from the smallest of devices to the largest, use the `.col` and `.col-*` classes. Specify a numbered class when you need a particularly sized column; otherwise, feel free to stick to `.col`.
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col">col</div>
<div class="col">col</div>
@@ -257,7 +257,7 @@ For grids that are the same from the smallest of devices to the largest, use the
Using a single set of `.col-sm-*` classes, you can create a basic grid system that starts out stacked and becomes horizontal at the small breakpoint (`sm`).
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col-sm-8">col-sm-8</div>
<div class="col-sm-4">col-sm-4</div>
@@ -275,7 +275,7 @@ Using a single set of `.col-sm-*` classes, you can create a basic grid system th
Don't want your columns to simply stack in some grid tiers? Use a combination of different classes for each tier as needed. See the example below for a better idea of how it all works.
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<!-- Stack the columns on mobile by making one full-width and the other half-width -->
<div class="row">
<div class="col-md-8">.col-md-8</div>
@@ -304,7 +304,7 @@ Use the responsive `.row-cols-*` classes to quickly set the number of columns th
Use these row columns classes to quickly create basic grid layouts or to control your card layouts.
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row row-cols-2">
<div class="col">Column</div>
<div class="col">Column</div>
@@ -315,7 +315,7 @@ Use these row columns classes to quickly create basic grid layouts or to control
{{< /example >}}
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row row-cols-3">
<div class="col">Column</div>
<div class="col">Column</div>
@@ -326,7 +326,7 @@ Use these row columns classes to quickly create basic grid layouts or to control
{{< /example >}}
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row row-cols-auto">
<div class="col">Column</div>
<div class="col">Column</div>
@@ -337,7 +337,7 @@ Use these row columns classes to quickly create basic grid layouts or to control
{{< /example >}}
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row row-cols-4">
<div class="col">Column</div>
<div class="col">Column</div>
@@ -348,7 +348,7 @@ Use these row columns classes to quickly create basic grid layouts or to control
{{< /example >}}
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row row-cols-4">
<div class="col">Column</div>
<div class="col">Column</div>
@@ -359,7 +359,7 @@ Use these row columns classes to quickly create basic grid layouts or to control
{{< /example >}}
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-4">
<div class="col">Column</div>
<div class="col">Column</div>
@@ -388,7 +388,7 @@ You can also use the accompanying Sass mixin, `row-cols()`:
To nest your content with the default grid, add a new `.row` and set of `.col-sm-*` columns within an existing `.col-sm-*` column. Nested rows should include a set of columns that add up to 12 or fewer (it is not required that you use all 12 available columns).
{{< example class="bd-example-row" >}}
<div class="container">
<div class="container text-center">
<div class="row">
<div class="col-sm-3">
Level 1: .col-sm-3

View File

@@ -19,7 +19,7 @@ toc: true
`.gx-*` classes can be used to control the horizontal gutter widths. The `.container` or `.container-fluid` parent may need to be adjusted if larger gutters are used too to avoid unwanted overflow, using a matching padding utility. For example, in the following example we've increased the padding with `.px-4`:
{{< example >}}
<div class="container px-4">
<div class="container px-4 text-center">
<div class="row gx-5">
<div class="col">
<div class="p-3 border bg-light">Custom column padding</div>
@@ -34,7 +34,7 @@ toc: true
An alternative solution is to add a wrapper around the `.row` with the `.overflow-hidden` class:
{{< example >}}
<div class="container overflow-hidden">
<div class="container overflow-hidden text-center">
<div class="row gx-5">
<div class="col">
<div class="p-3 border bg-light">Custom column padding</div>
@@ -51,7 +51,7 @@ An alternative solution is to add a wrapper around the `.row` with the `.overflo
`.gy-*` classes can be used to control the vertical gutter widths. Like the horizontal gutters, the vertical gutters can cause some overflow below the `.row` at the end of a page. If this occurs, you add a wrapper around `.row` with the `.overflow-hidden` class:
{{< example >}}
<div class="container overflow-hidden">
<div class="container overflow-hidden text-center">
<div class="row gy-5">
<div class="col-6">
<div class="p-3 border bg-light">Custom column padding</div>
@@ -74,7 +74,7 @@ An alternative solution is to add a wrapper around the `.row` with the `.overflo
`.g-*` classes can be used to control the horizontal gutter widths, for the following example we use a smaller gutter width, so there won't be a need to add the `.overflow-hidden` wrapper class.
{{< example >}}
<div class="container">
<div class="container text-center">
<div class="row g-2">
<div class="col-6">
<div class="p-3 border bg-light">Custom column padding</div>
@@ -97,7 +97,7 @@ An alternative solution is to add a wrapper around the `.row` with the `.overflo
Gutter classes can also be added to [row columns]({{< docsref "/layout/grid#row-columns" >}}). In the following example, we use responsive row columns and responsive gutter classes.
{{< example >}}
<div class="container">
<div class="container text-center">
<div class="row row-cols-2 row-cols-lg-5 g-2 g-lg-3">
<div class="col">
<div class="p-3 border bg-light">Row column</div>
@@ -142,7 +142,7 @@ The gutters between columns in our predefined grid classes can be removed with `
In practice, here's how it looks. Note you can continue to use this with all other predefined grid classes (including column widths, responsive tiers, reorders, and more).
{{< example class="bd-example-row" >}}
<div class="row g-0">
<div class="row g-0 text-center">
<div class="col-sm-6 col-md-8">.col-sm-6 .col-md-8</div>
<div class="col-6 col-md-4">.col-6 .col-md-4</div>
</div>