Bootstrap 4 Flashcards
col-, col-sm-, col-md-, col-lg-, col-xl-
grid sizes for bootstrap 4
.display-1
.display-2
.display-3
.display-4
Larger font-size and lighter font-weight to make headers stand out
<small></small>
Creates a lighter, secondary text in any heading
.text-muted .text-primary .text-success .text-info .text-warning .text-danger .text-secondary .text-white .text-dark .text-body .text-light
Contextual based text classes
.bg-primary .bg-success .bg-info .bg-warning .bg-danger .bg-secondary .bg-dark .bg-light
Background color classes for text. You’ll want to use these in conjunction with .text-* classes.
.table .table-striped .table-bordered .table-hover .table-dark .table-borderless
Classes that can be combined for the most part which creates tables with specific styling according to their names.
.table-primary .table-success .table-danger .table-info .table-warning .table-active .table-secondary .table-light .table-dark
Table classes that set the background of the and tags.
.thead-dark
.thead-light
Styling that makes the table header light or dark
.table-sm
Makes a regular table condensed with a small amount of padding
.table-responsive .table-responsive-sm .table-responsive-md .table-responsive-lg .table-responsive-xl
Creates a scrollable table when the window is below a certain threshold
.rounded
.rounded-circle
.img-thumbnail
.img-fluid (responsive)
Changes the shape of an image according to its description
.jumbotron
.jumbotron-fluid
A large space from which to display important information. Requires the use of a <div> element and be inside a .container or .container-fluid classed div</div>
.alert .alert-success .alert .alert-info .alert .alert-warning .alert .alert-danger .alert .alert-primary .alert .alert-secondary .alert .alert-light .alert .alert-dark
Used to display alerts with contextual background colors. These can be dismissed with Xs on the right hand side.
Must be created within a DIV tag.
alert-link
Added to an alert text to change the color to one that accents the alert contextual background colors
.alert-dismissible
.close
data-dismiss=”alert”
.fade
.show
Used to create an alert that is closable using a × X symbol. Fade and Show are added classes to make the alert fade out when dismissed.
<div>
×
</div>
.btn .btn-* classes can be used on 3 elements
<a></a>
</a>
.btn .btn .btn-primary (blue) .btn .btn-secondary (grey) .btn .btn-success (green) .btn .btn-info (teal) .btn .btn-warning (gold) .btn .btn-danger (red) .btn .btn-dark (black) .btn .btn-light (white) .btn .btn-link (white)
Used for styling bootstrap 4 buttons
.btn .btn-outline-primary .btn .btn-outline-secondary .btn .btn-outline-success .btn .btn-outline-info .btn .btn-outline-warning .btn .btn-outline-danger .btn .btn-outline-dark .btn .btn-outline-light text-dark
Used to style buttons where the borders and text are contextual colors instead of the background
.btn .btn-lg
.btn .btn-sm
Makes button sizes small or large based on description
.btn-block
Makes a button that stretches to fill the containers width
.btn-group (parent div)
.btn .btn-*
.btn-group-lg
.btn-grou-sm
Creates a group of link buttons with styling. -lg and -sm make the buttons smaller or larger.
.badge .badge-primary .badge .badge-secondary .badge .badge-success .badge .badge-danger .badge .badge-warning .badge .badge-info .badge .badge-light .badge .badge-dark
Used with the SPAN tag, creates a “badge” which has a dark background , light text, and rounded button like appearance.
.badge .badge-pill .badge-success
.badge-ill makes the badges “pill shaped” by changing the border radius on the default badge styling.
.progress
.progress-bar .progress-bar-striped
.progress-bar-animated
.bg-*
Creates a progress bar DIV
Parent DIV .progress
Child DIV .progress-bar
requires styling with a width attribute
UL .pagination LI .page-item A .page-link .pagination-lg .pagination-sm .active .disabled
Used to create a pagination navigation menu. You create it using a UL tag with .pagination for the container. You create the list using LI with .page-item class. Then inside that you create the anchors using .page-link class.
.active highlights the current navigation page.
UL .breadcrumb
LI .breadcrumb-item
Creates a bread crumb navigation styled list of page structure you’ve visited.
Photo / Summer / Italy
UL .list-group
LI .list-group-item .list-group-item-action
.list-group-item-success .list-group-item-secondary .list-group-item-info .list-group-item-warning .list-group-item-danger .list-group-item-primary .list-group-item-dark .list-group-item-light
.active
.disabled
Creates a “list group” which is a list of items, that when hovered highlights the background color and font color automatically based on contextual list group class.
What is a “card”?
A bordered box with padding around the contents, includes options for headers, footers, contents, colors etc
Think of it like a license card for content
.card
.card-header
.card-body
.card-footer
.bg-* (background-color to cards)
.card-title
IMG .card-img-top
IMG .card-img-bottom
Creates a bootstrap 4 card, cards are created using DIV elements.
.card-title removes the bottom margins for P elements if it’s the last child. It adds a blue color to any link with hover affects.
Add the .card-img.top/bottom outside the .card-body to span the entire width.
.card-img-overlay
Allows elements to be created in front of the cards background image set with card-img-top or card-img-bottom.
.card-columns (DIV)
.card-text (p)
Creates a column of cards. You can place all your cards inside the .card-columns wrapper div to create a group of cards.
.card-deck (DIV)
Creates a group of cards with equal height and widths, these automatically adjust as you insert more cards.
These cards have spaces in between them, not to be confused with a card-group which each card hugs the other without spacing.
.card-group (DIV)
Creates a group of equally tall and wide cards that fit snugly against the others.
.dropdown (DIV) .dropdown-toggle ( button ) data-toggle="dropdown" (button) .dropdown-menu (DIV) .dropdown-item (A)
.dropdown-item .active
.dropdown-item .disabled
Creates a basic dropdown menu from buttons that expand when clicked. Allows 1 selection.
.dropdown-divider (DIV)
Used to create a dividing line between drop down menu items.
.dropdown-header (DIV)
Used to create a header section for the drop down menu selections
.dropdown-menu .dropdown-menu-right
Allows the drop down to align to the right hand side.
.dropup (DIV)
Creates a dropup menu that pops up instead of down
.dropdown-item-text (A)
.dropdown-item-text (SPAN)
Used for creating plain text dropdown items. Can be used with (A) or (span) to be a link or plain text.
data-toggle=”collapse” (button)
data-target=”#target” (button)
.collapse (div with id #target)
.show
Creates a collapsible div that is activated with a button press.
.button data-toggle=”collapse” data-target=”#demo”.Collapsable.button
.div id=”demo” class=”collapse”.words.
.show will show the content by default
What is an “accordian”?
A group of collapsible divs with content inside each that will open/close like a collapsible toggle item.
.data-parent=”#targetDiv”
Used to create accordians, used in a child DIV to reference the parent container of all collapsible DIVs.
DIV id="accordian" DIV data-parent="#accordian" DIV content DIV data-parent="#accordian" DIV content
.nav (UL)
.nav-item (LI)
.nav-link (A)
.nav-justified
.disabled
.active
Creates a basic horizontal nav menu
.nav .justify-content.center (UL)
.nav .justify-content-end (UL)
Aligns the navigation menu to the center, or right. Default is to the left.
.nav .flex-column (UL)
Creates a vertical navigation menu
.nav .nav-tabs (UL)
.nav-item (LI)
.nav-link (A)
.nav-justified
.disabled
.active
Makes the normal navigation links into a tab appearance. That folder like appearance you’re looking for
.nav .nav-pills (UL)
.nav-item (LI)
.nav-link (A)
.nav-justified
Creates that classic rounded square pill style of the navigation menu.
What are toggleable tabs?
Tab style, where each tab (think of folder appearance) shows the contents of that tab when clicked.
.navbar (NAV)
.navbar-nav (UL)
.nav-item (LI)
.nav-link (A)
.navbar-expand-sm/md/lg/xl
Used to create a basic navigation bar in bootstrap. .navbar-expand-* is used to tell the browser what size the navigation menu will collapse or go vertical when shrunk.
.justify-content-center (NAV)
.navbar-brand (A)
Used to center navbar content to the center of the element. .navbar-brand is used to give styling to the logo name via text placed in between the anchor tags.
.navbar-brand can accept images, will automatically scale the image to fit vertically.
.navbar-dark (NAV)
.navbar-light (NAV)
Used to make the text in the dropdown menus white or black, “light” means dark text, “dark” means light text.
.navbar-expand-md (NAV) .navbar-toggler (BUTTON) data-toggle="collapse (BUTTON) target="#navbar" (BUTTON) .navbar-toggler-icon (SPAN) .collapse .navbar-collapse (DIV) id="navbar" (DIV)
Creates a collapsible navbar menu which collapses on the size setting you set in the first NAV.
In bootstrap the collapsible menus are called togglers
.navbar-expand-md
If you remove .navbar-expand-md you will only have the navbar toggle icon which is a toggle dropdown.
.dropdown (LI)
.dropdown-toggle (A)
.data-toggle=”dropdown” (A)
.dropdown-menu (DIV)
Used to create a drop down navbar
You can use a form tag with a class of .form-inline
to create a form inside a bootstrap navigation bar menu to have a handy search functionality.
.input-group-prepend
.input-group-append
Adds icons to your search menu making it look better
.navbar-text (SPAN)
Aligns non link items (text) inside the navbar
.fixed-top (NAV)
.fixed-bottom
Used to fix a navigation bar at the top or bottom of the page
.form-group (DIV)
.form-control (INPUT)
Used to create grouped form sections that group the labels and input elements together neatly.
.form-inline (FORM)
.form-check-label (LABEL)
.form-check-input (INPUT)
Used to create an inline form. .form-check-label and input created a remember me check box.
input type must be decared
or it won’t be styled properly in bootstrap
.form-check (DIV)
.form-check-label (LABEL)
.form-check-input (INPUT)
value=””
.form-check-inline (DIV)
Used to create a check box form in bootstrap
.form-control .form-control-sm (INPUT)
.form-control .form-control-lg (INPUT)
.form-control-plaintext
placeholder=”some text”
Changes the form size of the input elements.
Plaintext and placeholder are used to create inputs with text inside that disappear when you click to enter info
What sections build up a boot strap carousel?
- ) Create container div
- ) Create carousel indicators (ul with lis )
- ) Create the slideshow portion (divs with images)
- ) Create left and right controls, which are anchors with special classes
.carousel .slide data-ride=”carousel” (DIV)
Used to create the main container of a carousel
.carousel-indicators (UL)
data-target=”#demo”
data-slide-to=”0”
.active
Used to create the indicator section
data-target tells the carousel which targets to use, usually the same name for each
data-slide-to tells the carousel what order to use the slides, usually 0 1 2 etc
.carousel-inner (DIV)
.carousel-item (DIV)
Used to create the actual slide show, 2 nested divs, with an img inside
.carousel-control-prev (A)
.carousel-control-next (A)
.carousel-control-prev-icon (SPAN)
.carousel-control-next-icon (SPAN)
Used to create the controls to the carousel
.carousel-item (DIV)
.carousel-caption (DIV)
Used to create captions for each image slide
How do you create a modal?
Use a button or link to launch the modal, link it to a div wrapper with the ID
data-toggle=”modal” (BUTTON)
data-target=”#mymoda” (BUTTON)
Creates a button from which you can launch a modal.
.modal .fade (DIV)
.modal-dialog (DIV)
.modal-content (DIV)
Creates the main wrapper using 3 DIV elements, inside these you will add the modal header body and footer.
.modal-header (DIV)
.modal-title (header)
.modal-body (DIV)
.modal-footer (DIV)
Used to create the skeleton of the modal content. Inside each you can add whatever content you want.
.modal-dialog .modal-sm
.modal-dialog .modal-lg
Used to change the default size of the modal window that pops up
data-toggle=”tooltip” (A)
title=”contents” (A)
data-placement=”top” (A)
Used to create a tool tip that pops to the top, right, bottom or left
In order for tool tip popups to work properly, what must you enable in bootstrap 4?
The jquery function must be called in the document.
$(‘[data-toggle=”tooltip”]’).tooltip();
In order for popovers to work, what must you include?
A jquery function must be called for popovers
$(‘[data-toggle=”popover”]’).popover();
data-toggle=”popover” (A)
title=”contents” (A)
data-placement=”top” (A)
data-trigger=”hover” (A)
Creates a pop over affect when hovering over an anchor or element.
What is a “scroll spy”?
A scrollable webpage with elements that are linked to a menu. When you scroll to a corresponding section, its menu item will be highlighted to let you know you’re in that section. It also lets you jump using the menus.
.border .border-0 .border .border-top-0 .border .border-right-0 .border .border-bottom-0 .border .border-left-0
Used to quickly create no borders, or border styling just on one side of an element
.border .border-warning
.border .border-success
etc
Used to create border colors around an element.
.rounded .rounded-top .rounded-right .rounded-bottom .rounded-left .rounded-circle .rounded-0
Changes an elements border radius via classes
.clearfix (DIV parent)
.float-left (DIV child)
.float-right (DIV child)
Used to create a section which uses floated content
.mx-auto
Used to auto center elements and content, basically a short version of margin auto
.w-25 .w-50 .w-75 .w-100 .mw-100
Creates elements with widths of certain common percentages, which correlate to the numbers after the dash
w = width mw = max width
.h-25 .h-50 .h-75. .h-100 .mh-100
Creates elements with heights which have a percentage of its parents height.
How can you name classes that adjust the spacing of an element in bootstrap?
By using the m p method coupled with a key letter to set which direction the padding or margins will be applied
Example
mt-1
Will apply a level 1 amount of margin, to the top of an element
.m = margin .p = padding t = top b = bottom l = left r = right x = left and right y = top and bottom -*- = all sides
0 = 0 1 = .25rem 2 = .5rem 3 = 1rem 4 = 1.5rem 5 = 3rem
Examples
tp-5 class will adjust the top padding of an element 3 rem in distance
.m-*-5 = 3 rem on all sides
.shadow-none
.shadow-sm
.shadow-lg
.shadow
Creates a shadow for an element, default is medium using only .shadow
.embed-responsive .embed-responsive-21by9 .embed-responsive16by9 .embed-responsive4by3 .embed-responsive1by1 .embed-responsive-item
Creates a responsive embedded element, dependent on its parents size
Create a parent element with .embed-responsive. Then create a child with .embed-responsive-item inside
.visible
.invisible
Changes the visibility of an element. This doesn’t set display: none.
.fixed-top
.fixed-bottom
Places an element fixed at the top or bottom
.sticky-top
When you scroll past an item, it will stick to the top only when you scroll past it.
Will not work in IE11 and earlier
.close
Used for styling closing elements such as modals and alerts. It floats right by default.
Flex boxes do what in bootstrap 4?
Creates a parent div that makes all children ‘flex” items. Which are basically items that can be arranged and sized based on percentages.
.d-flex
.d-inline-flex
Creates a parent DIV for flex items. d-flex shows the background of the flex box spanning the whole space available. .d-inline-flex only wraps the children elements not showing the background color of the flex box by default.
.d-flex .flex-row
.d-flex .flex-row-reversed
Creates a row where you can stack items next to each other on the left or right depending on whether its reversed or not.
.d-flex .flex-column
.d-flex .flex-column-reverse
Stacks items vertically and takes all available space.
.d-flex .justify-content-start .d-flex .justify-content-end .d-flex .justify-content-center .d-flex .justify-content-between .d-flex .justify-content-around
Creates justified content. Each type will justify your content in a different way.
Start is left aligned no space end is right aligned no space center is center aligned no space between is as far apart as possible with gaps around is equally gapped items
.flex-grow-1
Makes an element take up the remaining space in a d-flex group
.d-flex (DIV)
.order-1 (DIV)
.order-2 (DIV)
etc
Sets priority to which element will be styled first, second third etc in a flex group. This class is used on child elements of the .d-flex parent
.d-flex (DIV)
.mr-auto (DIV)
.ml-auto (DIV)
Used to automatically push items to the right. This is assigned to the child of the .d-flex parent.
mr-auto pushes to the right
ml-auto pushes to the left
.d-flex .align-items-start
.d-flex .align-items-bottom
.d-flex .align-items-center
.d-flex .align-items-stretch
Aligns items vertically
start = top end = bottom center = center base = ??? stretch = items height are 100%
.d-flex (parent div)
.align-self-start (child div)
.align-self-bottom (child div)
.align-self-center (child div)
.align-self-stretch (child div)
Used to align individual flex items instead of whole rows. These are used on children of the parent .d-flex
Each flex item can be responsive
By adding flex classes to flexed elements
You can make any flex element responsive by adding the responsive keywords to it
.d-sm-flex
An example will only flex for small content
How can you easily align media with groups of content using bootstrap 4?
using the .media class parent with a .media-body child inside
.media (DIV)
.media-body (DIV)
.media defines the parent wrapper and .media-body defines the content that will be styled together with the media