bootstrap Flashcards
To create a container for Bootstrap’s grid -> assign a class of “container” to a <div>:
<div></div>
</div>
- > div becomes a Bootstrap container
- > has a width relative to a user’s screen size
- > horizontally centered, has a left and right margin.
Container to take up the entire width of the screen
<div class="container-fluid"></div>
To integrate Bootstrap into a project, include TWO tags and the Bootstrap library inside the tags
To create a row for the Bootstrap grid: assign a class of "row" to an element.
By default, a row will take up the entire width of its parent container.
At most, a row will accommodate 12 columns.
eg:
<div>
<div>
</div></div>
To create a column, assign an element with the class of "col" eg: <div class="container"> <div class="row"> <div class="col"> </div> </div></div>
By default, a column will take up the entire width of its parent row.
Adjust the width of a column by add a hyphen a number to the “col” class:
<div>
<p>This is the width of 8 columns.</p></div>
COL-AUTO use the content to set the width of a column: append "auto" to the class of the column:
<div>
<p>This content determines the width of the parent column</p></div>
Bootstrap categorizes screen sizes into 5 categories/breakpoints: extra small, small, medium, large, and extra large.
{breakpoint} can be sm, md, lg, or xl
Notice that there is no extra small or XS breakpoint. If we omit {breakpoint}, it is by default for extra small screens.
{width} can be set from 1 to 12 and assigns a width to the column.
When we set a {breakpoint}-{width}, it means that we want our column to have that set width for screens that fit in the specified breakpoint range and other larger screens.
For instance:
<div>
</div>
The column in the example will be as wide as 8 individual columns on small screen sizes and also any larger screens (medium, large, and extra large).
<div></div>
- For extra small and small sized screens-> the column will take up the entirety of the row (width of 12 columns) -> implicitly applied.
- For medium-sized screens -> take up the width of 8 columns
- For extra large sized screens -> the column will have a width of 6 individual columns
add multiple classes to a column to determine how wide a column should be on specific breakpoints
What Bootstrap elements are immediate children of containers?
ROWS
Follow Bootstrap’s naming convention to have the column render as wide as 7 individual columns wide on small and medium sized screens. Also have the column render as wide as 5 individual columns on large and extra large screens.
<div></div>
To change the background color to green we need to assign the <div>‘s class a value of “bg-success” AND make the text white, add another class of “text-white”:
<div>
...
</div>
</div>