Bootstrap's Cards are content containers that are highly customizable. We're going to look at just the basic implementation.
card
- Class that dictates the element is a cardcard-body
- Adds padding to main content of the card.
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
You can add an image at the top of a card. Card images will automatically scale with the card.
Some quick example text to build on the card title and make up the bulk of the card's content.
See the Pen BS - Card-2 by Jon (@Middaugh) on CodePen.
Cards have a large number of custom classes that provide a way to have consistent looking content.
card-title
card-subtitle
card-text
card-link
Article 1 title
Article 1 subtitle
Lorem ipsum dolor sit amet consectetur adipisicing elit. Debitis iusto temporibus voluptatem et repellendus accusantium?
Read More
Article Source
See the Pen BS - Card-4 by Jon (@Middaugh) on CodePen.
Bootstrap themes are packages of HTML, CSS, and JavaScript that provide a consistent look to your Bootstrap powered website.
Bootstrap offers several predefined styles and behaviors. Most are designed around semantic usage.
Bootstrap button styles can be applied to
button
,
input
, and
a
btn
- this applies the look and behavior of the buttonbtn-[type]
- this applies the theme/color
See the Pen BS - Buttons by Jon (@Middaugh) on CodePen.
Bootstrap provides a great way to style forms and customize their layout.
Bootstrap applies a width of 100% to almost all of their form elements, but can easily be changed with additional classes.
form-group
- A container for a specific input. Primary purpose is to add spacing between inputscol-form-label
- Class for dictating a labelform-control
- applies Bootstrap's look and feel to an input.This markup generates a stacked form.
See the Pen BS - Forms by Jon (@Middaugh) on CodePen.
You can use Bootstrap's grid system to generate a horizontal form.
See the Pen BS - Form-2 by Jon (@Middaugh) on CodePen.
There are built in styles to help provide a visual indicator that there are missing fields.
is-valid
is-invalid
invalid-feedback
- Validation message. Automatically displays when input has
is-invalid
. There is a block of JavaScript that executes this. We'll look at it later.
See the Pen BS - Form-3 by Jon (@Middaugh) on CodePen.
Bootstrap has an opt-in approach for styled tables. You must add the class
table
to a
table
element to get a styled table
#
First Name
Last Name
Username
1
Mark
Otto
@mdo
See the Pen BS - Table by Jon (@Middaugh) on CodePen.
You can apply several global styles by using these classes on the parent table
table-striped
- Adds a different background to every other rowtable-bordered
- Adds borders to all table cellstable-hover
- Adds a different background when hovering over a rowThese can be applied to any row or column in a table.
<table>
<tr class="table-active">...</tr>
<tr class="table-primary">...</tr>
<tr class="table-secondary">...</tr>
<tr class="table-success">...</tr>
<tr class="table-danger">...</tr>
<tr class="table-warning">...</tr>
<tr class="table-info">...</tr>
<tr class="table-light">...</tr>
<tr class="table-dark">...</tr>
</table>
See the Pen BS - Table by Jon (@Middaugh) on CodePen.
There are many classes that apply small changes to images that help make them more mobile friendly.
The
img
tag is an inline element by default. Using the class
img-fluid
forces the element to always take up 100% of the space available ot it.
You can use the class
img-thumbnail
to apply a 1px border for a better appearance.
Rounded corners are apart of Bootstrap's Utilities, but you can easily apply them to images for better appearance
See the Pen BS - Images by Jon (@Middaugh) on CodePen.
Bootstrap contains a large number of utilities to help with small layout changes.
Left aligned text on all viewport sizes.
Center aligned text on all viewport sizes.
Right aligned text on all viewport sizes.
[property]
[sides]
-
[size]
p
- paddingm
- margint|b|l|r
- top, bottom, left or rightx|y
- both sides or top and bottomblank
- applies to all sidesmr-1
- small margin leftm-5
- large margin on all sidesmx-auto
- left & right auto marginp1
- small padding on all sidespb-1
- small padding on bottom.d-none
.d-inline
.d-inline-block
.d-block
.d-flex
.w-25
.w-50
.w-75
.w-100
.w-25 is 25% of what? It's 25% of a SASS variable that you set in your theme.
Bootstrap's auto configured slide toggle feature.
You can configure it with just HTML
(slide toggle is a technical term)
data-toggle="collapse"
href="[selector]"
data-target="[selector]"
Link with href
See the Pen BS-Collapse by Jon (@Middaugh) on CodePen.
Bootstrap's Navigation component takes care of most of the typical scenarios for navigation.
navbar
- base classnavbar-expand-lg
- expands at lg breakpoint. Can be sm|md|lg|xlnavbar-light
- applies a black foreground. -darkbg-light
- applies a light background. -dark, -primary
See the Pen BS-Basic Nav by Jon (@Middaugh) on CodePen.
Dropdown link
See the Pen BS-Basic Nav - drop down by Jon (@Middaugh) on CodePen.
Bootstrap provides an easy to use Carousel that can be implemented without needing to write any JavaScript.
Bootstrap's carousel is based off of images and allow optional captions.
See the Pen BS - Carousel by Jon (@Middaugh) on CodePen.
See the Pen BS - Carousel-Indicators by Jon (@Middaugh) on CodePen.
Indicators displays what slide is currently active. They are made up from list items.
See the Pen BS - Carousel-Indicators by Jon (@Middaugh) on CodePen.
How might we take this a step further? How about custom css on the indicators.
...
...
See the Pen BS - Carousel-Captions by Jon (@Middaugh) on CodePen.
Like many other Bootstrap JavaScript components, can be implemented without needing to code out any JavaScript. You will need to use JavaScript if you need to utilize its more advanced functionality.
There are three main components needed for the structure of a Bootstrap Modal.
Modal title
...
See the Pen UA-BS-Modal-4 by Jon (@Middaugh) on CodePen.
Completed folder is switched.