Bootstrap 4 Flashcards

1
Q

What is the responsive meta tag?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the responsive meta tag?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
What does this code do...
<div class="container">
  <div class="row">
    <div class="col">
      1 of 3
    </div>
    <div class="col-6">
      2 of 3 (wider)
    </div>
    <div class="col">
      3 of 3
    </div>
  </div>
</div>
A
Three columns, middle one taking up half space (6 of 12) the other two equally distribute space between them.
Compare to...
<div class="container">
<div class="row">
    <div class="col">
      1 of 3
    </div>
    <div class="col-5">
      2 of 3 (wider)
    </div>
    <div class="col">
      3 of 3
    </div>
  </div>
</div>
Which gives 5/12 to the middle column and each of the two remaining columns get 3.5 each (3.5/7 remaining)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Make three equal width columns in Bootstrap.

A
<div class="container">
  <div class="row">
    <div class="col-sm">
      One of three columns
    </div>
    <div class="col-sm">
      One of three columns
    </div>
    <div class="col-sm">
      One of three columns
    </div>
  </div>
</div>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
What does this code do...
<div class="container">
  <div class="row">
    <div class="col">
      1 of 3
    </div>
    <div class="col-6">
      2 of 3 (wider)
    </div>
    <div class="col">
      3 of 3
    </div>
  </div>
</div>
A

Three columns, middle one taking up half space (6 of 12) the other two equally distribute space between them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you make a basic Bootstrap grid with one column?

A
<div class="container"> 
   <div class="row"> 
      <div class="col">I'm your content inside the grid!</div> 
   </div> 
</div>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the three basic rules of the Bootstrap grid?

A

The Rules of the Grid:

1) Columns must be the immediate child of a Row.
2) Rows are only used to contain Columns, nothing else.
3) Rows should be placed inside a Container.

The Rows & Columns always work together, and you should never have one without the other.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can a Bootstrap container have elements & content not inside rows & columns?

A

The Container can be used to hold any elements and content. It’s not only used for the Grid Rows & Columns. For example, this is perfectly valid Bootstrap markup:

<div class="container">
   <h2>My Heading</h2> 
   <div class="row"> 
      <div class="col">I'm content inside the grid!</div> 
   </div> 
</div>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the two types of Bootstrap containers?

A

1 — Fixed-width container to center your layout in the middle:

<div></div>

2 — Full-width container for a layout the spans the entire width:

<div></div>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What’s wrong with the following Bootstrap code?

<div>
<h2>Here is my heading</h2>
</div>

A

Columns, and only columns, are placed inside the Row.
Content is placed inside the Columns.

<div>
<div>Happy :-) This is the right way.</div>
</div>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a Bootstrap gutter?

A
Space between each column. 
To have none, make a no-gutters class and assign to the row..

.no-gutters {
margin-right: 0;
margin-left: 0;

  > .col,
  > [class*="col-"] {
    padding-right: 0;
    padding-left: 0;
  }
}

<div>
<div>.col-12 .col-sm-6 .col-md-8</div>
<div>.col-6 .col-md-4</div>
</div>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What happens if you put more than 12 columns per row?

A

<div>
<div>.col-9</div>
<div>.col-4<br></br>Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.</div>
<div>.col-6<br></br>Subsequent columns continue along the new line.</div>
</div>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
Bootstrap order classes: 
<div class="container">
  <div class="row">
    <div class="col">
      First
    </div>
    <div class="col order-12">
      Second
    </div>
    <div class="col order-1">
      Third
    </div>
  </div>
</div>
A

First Third Second

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are order-first and order-last?

A

There are also responsive .order-first and .order-last classes that change the order of an element by applying order: -1 and order: 13 (order: $columns + 1), respectively. These classes can also be intermixed with the numbered .order-* classes as needed.

Output:
Third Second First

<div class="container">
  <div class="row">
    <div class="col order-last">
      First, but last
    </div>
    <div class="col">
      Second, but unordered
    </div>
    <div class="col order-first">
      Third, but first
    </div>
  </div>
</div>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What’s this Bootstrap code do?

<div>
<div>.col-md-4</div>
<div>.col-md-4 .offset-md-4</div>
</div>

<div>
<div>.col-md-3 .offset-md-3</div>
<div>.col-md-3 .offset-md-3</div>
</div>

<div>
<div>.col-md-6 .offset-md-3</div>
</div>

A

responsive .offset- grid classes

CMD4         CMD4
      CM3        CM3
      CMD603
==============
4       (blank 4)         4
(blank 3) 3 (blank 3) 3
(blank 3) 6     

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.
These classes increase the left margin of a column by * columns. For example, .col-md-offset-2 moves .col-md-2 over four columns. .col-md-offset-* to leave a particular number of virtual Bootstrap columns to the left of any column (kind of like invisible place holders).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
What does the following code do?
<div class="row">
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
</div>
<div class="row">
  <div class="col-md-8">.col-md-8</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
  <div class="col-md-6">.col-md-6</div>
  <div class="col-md-6">.col-md-6</div>
</div>
A

Using a single set of .col-md-* grid classes, you can create a basic grid system that starts out stacked on mobile devices and tablet devices (the extra small to small range) before becoming horizontal on desktop (medium) devices.

Each row will become stacked lower than md size (<750px) (xs and sm are stacked) .col-xs- .col-sm-

17
Q

Describe the difference between .container and .container-fluid.

A

Use .container-fluid when you want your page to shapeshift with every little difference in its viewport size.

Use .container when you want your page to shapeshift to only 5 kinds of sizes, which are also known as “breakpoints”.
)

18
Q

What does the following code do?

<div class="col-md-3 col-sm-6 col-xs-12">
   <div class="service-items">
      <div class="icon">
         <span class="glyph"></span>
      </div>
   </div>
</div>
A

One column for xs displays.
Two columns for sm displays
Four columns for md and larger displays.

19
Q

Screen sizes in Bootstrap.

A

Screen sizes generally use the min-width condition. Default is extra-small, for example col-6 is half viewport at any viewport size (it’s like col-xs-6)

Extra small (under 576px) - no media query because styling gets overwritten by media queries for bigger sizes. (example: col-6 takes up half viewport any size)

.col-sm-6 - will span 1/2 viewport above 576px. Will span full width below.

.col-md-6 will span 1/2 viewport above 768px and full width below that.

.col-lg-6 will span 1/2 viewport above 992px, full width below.

.col-xl-6 will span 1/2 viewport above 1200px, full width below

.col-xl-6

20
Q

What’s this do?

.d-none .d-md-block .d-xl-none

A
.d-none .d-md-block .d-xl-none will hide the element for all screen sizes except on medium and large devices.
To show an element only on a given interval of screen sizes you can combine one .d-*-none class with a .d-*-* class, for example.
21
Q

What’s this code do?

.d-md-none .d-lg-block

A

Hidden only on md

22
Q

What’s this do?

.d-none .d-md-block .d-lg-none

A

Visible only on md

23
Q

How would you hide on screens wider than lg

A

<div>hide on screens wider than lg</div>

24
Q

How do you hide on screens smaller than lg

A

<div>hide on screens smaller than lg</div>

25
Q

Using Bootstrap, how would you show something on screen only, but not during printing?

A

<div>Screen Only (Hide on print only)</div>

26
Q

Using Bootstrap, how to show something only in print view but not on screen?

A

<div>Print Only (Hide on screen only)</div>

27
Q

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).

A
<div class="container">
  <div class="row">
    <div class="col-sm-8">col-sm-8</div>
    <div class="col-sm-4">col-sm-4</div>
  </div>
  <div class="row">
    <div class="col-sm">col-sm</div>
    <div class="col-sm">col-sm</div>
    <div class="col-sm">col-sm</div>
  </div>
</div>
28
Q

<div>
<div>
<div>.col-12 .col-md-8</div>
<div>.col-6 .col-md-4</div>
</div></div>

A
29
Q

<div>
<div>.col-6 .col-md-4</div>
<div>.col-6 .col-md-4</div>
<div>.col-6 .col-md-4</div>
</div>

A
30
Q

Use flexbox alignment utilities to vertically align columns. Vertical alignment of flex items when the flex container (row) has a min-height.

A
<div class="container">
  <div class="row align-items-start">
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
  </div>
  <div class="row align-items-center">
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
  </div>
  <div class="row align-items-end">
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
  </div>
</div>
-----------------
31
Q
Assuming row has min-height set, what will this do? 
<div class="container">
  <div class="row">
    <div class="col align-self-start">
      One of three columns
    </div>
    <div class="col align-self-center">
      One of three columns
    </div>
    <div class="col align-self-end">
      One of three columns
    </div>
  </div>
</div>
A

three column row. First column begins at top, second in middle, third at end.

  - --
32
Q
<div class="container">
  <div class="row justify-content-start">
    <div class="col-4">
      One of two columns
    </div>
    <div class="col-4">
      One of two columns
    </div>
  </div>
</div>
A

Two columns in a row, justified to the left (start)

COL-1 COL-2 blank9

33
Q
<div class="row justify-content-center">
    <div class="col-4">
      One of two columns
    </div>
    <div class="col-4">
      One of two columns
    </div>
  </div>
A

Two columns centered in a row.

blank-2 col-4 col4 blank-2