---
# System prepended metadata

title: 'TINKER: Bootstrap 5.x'
tags: [' bootstrap', ' html', ' css', ' tinker', mstu5003]

---

---
tags: mstu5003, tinker, html, css, bootstrap
---

# TINKER: Bootstrap 5.x

:::info
Group Members: Diandian Huang
:::

---

**See demonstration: https://codepen.io/jmk2142/pen/yLXdqbd**
<!-- (Old version 4.x): https://codepen.io/jmk2142/pen/EwKXbo -->

[codepen External Bootstrap CSS URL](https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css)

After our run with basic HTML/CSS and trying to produce our websites, many of you have probably noticed that it's actually quite a chore to get your pages and parts of to align correctly using `margins` and `padding`, different `width and height units` like `px` and `%`. Actually, there are even more: `em rem vh vw` etc. To make matters even more difficult, I think you all have probably experienced how the representations of your visual layouts and definitions of dimensions is highly impacted by the hierarchy of your elements and what rules are set on the parents and grandparents of a particular thing.

The nice thing is: **there are solutions to this.**

## Responsive Design and Bootstrap

This week is mostly about continuing to practice the basic `html/css` we've learned last week in preparation for having some content and interactive user interfaces that we can use to make Javascript more interesting.

Thus, I wanted this week's tinker problem to be around something called Bootstrap - which is simply a `CSS` file that two people at Twitter created so that you don't have create all those intricate rules yourself.

Bootstrap provides a bunch of pre-defined helper classes that do things for the [LAYOUT](https://getbootstrap.com/docs/5.2/layout) Things like:

- Set margins and paddings for you and provide a simple, predictable, yet flexible way to layout content at the page level, (see [Grid System](https://getbootstrap.com/docs/5.2/layout/grid/).)
- Set rules that will automatically make your page change it's layout depending on what kind of screen is being used to view it. (e.g. 3 columns on a big screen but only 1 and content stacked in order if on mobile.)
- Provide basic pretty styles to your typography and interfaces.
- Provide ways to create components, which are groups of different elements to make a more sophisticated larger thing.
- Provide more advanced javascript driven interactive interfaces and features.

Bootstrap isn't the only option here. There are many different kinds of 3rd party libraries which we call HTML/CSS Frameworks. Examples:

- https://getbootstrap.com/
- http://materializecss.com/
- https://getmdl.io/components/index.html
- https://semantic-ui.com/usage/layout.html

Bootstrap traditionally was one of the more popular ones as it's pretty easy to pick up and made significant contributions to this space. I will support Bootstrap in this class but if you learn to use Bootstrap, the basics concepts apply to other frameworks. You just need to learn the framework specific `classes`.

Like mentioned, they generally share common features. The basic thing to keep in mind with these frameworks is:

- Use the provided **GRID SYSTEM**.
- The results are driven by the correct use of the framework provided `classes`.
- In using their `classes`, you are agreeing to their _opinions_ about how to use the classes.
  - This means, `classes` tend to have distinct effects based on how they are used *together* and the *hierarchy* in which they are used.
  - Thus, you MUST follow their specifications exactly.

:::success
**RECOMMENDED STUDY**

To get the most of Bootstrap:

- Align your studies with FCC: Front End Libraries > Bootstrap unit
- Read the Bootstrap documentation on Grids carefully: https://getbootstrap.com/docs/5.2/layout/grid/ --- They work in conjunction with `containers > rows > columns`

    - [Containers](https://getbootstrap.com/docs/5.2/layout/containers/)
    - [Grid](https://getbootstrap.com/docs/5.2/layout/grid/)
    - [Columns](https://getbootstrap.com/docs/5.2/layout/columns/)
- Browse through the https://getbootstrap.com/docs/5.2/content page (i.e. typography, code, images, tables, figures) to be aware of the `classes` available to you to do certain stylistic things.
- Browse through the https://getbootstrap.com/docs/5.2/components page to be aware of the _components_ available to you through Bootstrap and a gist of how `classes` are used to create these components.
:::

## Tinker Tasks

- Like we did with the prior Tinker, fork the codepen to play with it.
- **COMPARE AND CONTRAST** this Tinker (which uses Bootstrap) with [last week's codepen](https://codepen.io/jmk2142/pen/dVMRRq).
- Use the guiding prompts and questions to **manipulate** the code **one thing at a time** and _see_ what happens.
- **Articulate** your understanding and share your findings and insights with your weekly group and/or the class.

### FRAMEWORK: OVERARCHING

- In the settings of the CSS Pane (click on the gear) there is a section called Add External CSS. Remove the resource (Bootstrap) line.
  - What happens to the page and why?
>   The layout, color and size of the pictures changed.
  The format of the table was also cleared.

  - You can add the resource back: https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css
  Enter the above resource directly into your browser URL input to go to the page and scan through the resource.
  - What is Bootstrap really?
  :::warning
The layout, color and size of the pictures changed.
The format of the table was also cleared.
:::
  - You can add the resource back: https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css
- Enter the above resource directly into your browser URL input to go to the page and scan through the resource.
  - What is Bootstrap really?
:::warning
Bootstrap provides us a grid system to arrange HTML elements. It's design templates to help us customize typography, forms, buttons, navigation, and other interface components
:::
- I have a few CSS rules in the CSS pane. Comment them out.
  - What happens to the page and why?
:::warning
When we commented out the CSS rules for margins and paddings, the distance between each HTML elements shortened. 
:::
  - What is the relation between my CSS and the External Resource?
:::warning
The Boostrap provides a set of more general CSS rules, while the CSS rules in the CodePen help us specify some other rules. They complement each other. 
:::
  - How does my CSS "intersect" with the External Resource?
:::warning
The Boostrap have already set the margin, but the CodePen also have CSS rules for margin.
:::
  - What do you think is the sequence of how the External Resource and my CSS are loaded?
:::warning
The CodePen read the Bootstrap first then read our local CSS rules. The local CSS rules overwrite the external resource.
:::
  - What kinds of things could happen, if I am careless with my own CSS rules?
:::warning
The CSS rules will replace the external resources' rules. For instance, if we accidently change the color with CSS rules, it will overwrite the color set previously.
:::
  - Are you stuck with all of Bootstrap's rules? How does our own CSS come into play if we don't like a particular Bootstrap rule?
:::warning
We can re-define the CSS rules in CodePen, and overwrite the Bootstrap rules. 
:::
- Compare this Tinker's custom CSS vs. last week's CSS.
  - What kind of specific rules did I have to make last week that I did not have to do this week to achieve a very similar result?
:::warning
Last week's CodePen has tons of CSS rules in local while this week's CodePen only has a few lines.
:::
  - What then is the _advantage_ of using a framework like Bootstrap?
:::warning
It make our local CSS rules more readable and simple (save more lines). Some devices have the framework pre-loaded so using a framework will save their loading time.
:::
  - What are some _disadvantages_ of using a framework like Bootstrap?
:::warning
Sometimes it's hard to change the format of our target elements.
:::
- Compare the HTML from this week's Tinker vs. last week's Tinker HTML.
  - I use a class called `.container` in both. Is this a special `class`? Are they the same thing?
:::warning
They're not the same thing. Bootstrap has set specific rules for `.container` style, while last week's Tinker has local-defined CSS rules for `.container`  class.
:::
  - There are many more `classes` used in this week's Tinker. Where do these classes come from?
:::warning
They are defined in the Bootstrap, and we use these pre-defined classes to make our code more efficienct.
:::
- Remove classes like `img-thumbnail` and some of the `danger`, `info`, etc. classes in the table and/or try adding them to other elements. Might work, might not.
  - How do these kinds of `classes` relate and rely on the bigger structure and `class` rules of a framework?
:::warning
If we remove the classes, the decoration style defined by the bootstrap will disappear because it cannot select the target elements. If the classes move to other elements, the style will apply to that element.
:::
- Analyze the form and refer to https://getbootstrap.com/docs/5.2/forms. Try to convert this BASIC form to an **horizontal form** and/or an **inline form**. Some of the examples have extra attributes like `id`, `placeholder`.
  - Are the non-class attributes important in terms of getting Bootstrap to work? (How do you know?)
:::warning
Non-class attributes do not really change the format set by Bootstrap, but attributes like `id` and `for` will impact functionality of the input.
:::
  - If you deviate from the specifications, particularly: 1) the classes used, 2) the hierarchy expected, how might that affect your result?
:::warning
Bootstrap will have trouble selecting the targeted elements and therefore the format will change.
:::
- Manipulate the form to "exclude" certain classes as prescribed by the Bootstrap guide and examples.
  - How does not following the specifications affect the output?
:::warning
The format will change because the elements will fail to be selected.
:::
  - What are the key aspects you need to be paying attention to when learning and implementing these framework features?
:::warning
We need to pay attention to the classes and hierarchy to link the framework with the elements.
:::
  - What is the best way to learn how to use a new framework feature?
:::warning
To see how the existing bootstrap code correponds to the style and format, and experiment by changing the code to see its effect.
:::
- Think about your experience building a page from scratch last week.
  - What is your attitude on using, learning new frameworks like this?
:::warning
We would like to learn about more framework becasue they help our local codes looks more organized and readable.
:::


### GRID SYSTEM

```htmlmixed=
<div class="container">
  <div class="row">
    <div class="col-__">
      <!-- CONTENT -->
    </div>
  </div>
</div>
```

- FIND the above pattern(s) within the HTML.
  - Move a `.row` to the outside of a container. What happens?
:::warning
The margin of the container class disappeared because the hierarchy changed.
:::
  - Move a column outside a row but within a container. What happens?
:::warning
The hierarchy changed because the row nests the column now.
:::
  - What is the importance of using these three classes together `container`, `row`, `col-__` and in the correct hierarchical sequence?
:::warning
To help us organize the format of each element in the right way. A clear hierarchical sequence ensure our codes have a clear logic.
:::
- Manipulate some of the content inside the columns to different parts of the page, keeping in mind whether the content is inside a `row`, or a `container`, or none.
  - What happens when content falls outside of the columns?
:::warning
The format of the HTML content changes as their hierarchy changes. 
:::
- Manipulate the column classes to replace some `col-12` to `col-xl-4`. Then, drag your browser screen out to make it really large or really small. Or you can zoom in or zoom out of your browser to get the similar effect.
  - What does the `xs`, `sm`, `md`, `lg`, `xl`, `xxl` represent in the column `class` notation?
:::warning
We use`xs`, `sm`, `md`, `lg`, `xl`, `xxl` to define the maximum width of the column.
`xs`: extra small
`sm`: small
`md`: medium
`lg`: large
`xl`: extra large
`xxl`: extra extra large 

:::
- Manipulate the column classes to replace some `col-12` to `col-3`. This is partly dependent on how large your browser window is so you might have to play with the size or zoom in and out to see differences.
  - What does the `number` in the column name represent with respect to the GRID system?
:::warning
It indicates the number of template columns to span while there are 12 template columns available per row in standard grid.
:::
- Carefully observe and compare this column **class naming system** (i.e. _opinion_) that Bootstrap has, with the column naming system of these _other_ GRID SYSTEMS:
  - https://semantic-ui.com/collections/grid.html
    - Click on the `<>` on the page to see the actual code with `classes`
  - http://materializecss.com/grid.html
  - http://getskeleton.com/#grid
  - What are the similarities and what are the differences?
:::warning
1. Similarities: All frameworks devide the page into rows and columns. 
2. Differences:Bootstrap,Materialize,and SKELETON have 12 columns for each row while the Semantic UI divide horizontal space into 16 columns. Bootsrap,Semantic UI and Materialize are fluid responsive grid system while the Skeleton grid sets a max width of 960px.
:::
  - What is a Grid System _convention_ vs. _rule_? Can you give an example?
:::warning
Convention is the consistent classification of row and column, and rule is the naming method unique to each specific class naming system.
Example:
1. Skeleton:
```
 <div class="row">
    <div class="one column">One</div>
    <div class="eleven columns">Eleven</div>
  </div>
```
2. Materialize:
```
 <div class="row">
      <div class="col s12">This div is 12-columns wide on all screen sizes</div>
      <div class="col s6">6-columns (one-half)</div>
      <div class="col s6">6-columns (one-half)</div>
    </div>
```
3. Semantic UI:
```
 <div class="three column row">
    <div class="column"></div>
    <div class="column"></div>
    <div class="column"></div>
  </div>
```
4. Bootstrap:
```
<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>
```
:::
  - What would happen to my columns if I remove Bootstrap from my page?
:::warning
The pre-defined column would no longer work because the code defining column number is no longer there in HTML.
:::
  - Is the class, `col-xs-6` for example, really that special?
:::warning
It only changes the visual presentation i.e. the number of column, but does not substantially change the functionality of the website.
:::
- Visit the following link: [Grid System Explained](https://www.youtube.com/watch?v=Wqu-d_b3K-0)
  - What is the advantage of using popular tools like Bootstrap?
:::warning
Easy to apply the same framework to multiple projects so that we don't need to repetitive work.
:::

:::success
**Did you know?** As a student, you have access to the full Lynda.com / LinkedInLearning library. These are fantastic resources if you want to actually see the details of specific feature implementation.

Thing with these tutorials is that they tend to explain _how to do_ specific things, but don't quite address the issue of deeper understanding to explicitly address how concepts relate and tie together. That said, used in _conjunction_ with activities like the Tinkers, can be a very powerful combo.

To access Lynda.com:
- Log IN with your student account
  - https://www.linkedin.com/learning
- See the Bootstrap Essentials VIDEO Tutorial
  - https://www.linkedin.com/learning/bootstrap-5-essential-training
:::

- How does the combination of different ways of observing, manipulating, thinking, and applying code help learners to develop a comprehensive mental model of understanding?
:::warning
It gives you a sense of the structure of codes (hierarchy and sequence), and how changing certain codes impact the visual output while others don't.
:::


## COMPONENTS

- Browse through the different [COMPONENTS](http://getbootstrap.com/components/) of the Bootstrap Framework and observe **_the pattern_** of how the documentation is presented. Experiment with BUTTONS for a good example: https://getbootstrap.com/docs/5.1/components/button-group/
  - When learning to use new components in a framework, what do you think is the best practice on how to learn about the feature?
:::warning
This documentation provide great examples for each new component. We can learn from these example, and try to follow the syntax in our own code.
:::
- In my table, I have "Extremely Deadly" as a label of sorts, that is bright red which is defined by the `.bg-danger` class. OVERRIDE this rule in your custom CSS pane to make `.bg-danger` a `pink` color using the following value: `pink !important`
  - Try removing the `!important` and what happens? Why?
:::warning
When we include `!important` in the rule, the `pink` color will be applied to the element. When we remove `!important`, the `pink` color will not be applied to the element.
:::
  - What affect might this have on other parts of my page?
:::warning
Other parts of the page doesn't change, because only one element has this `.bg-danger` class.But if there are multiple `.bg-danger` classed, all of them will be affected.
:::
- Pick a few different components you find interesting. Try to implement them into your Tinker fork on Codepen.
  - Share with your group what you found about the experience of learning to use new features and what your takeaway was.

## JAVASCRIPT

:::info
Some components, mostly those that will react to user interaction are driven by Javascript. We aren't quite there yet. You are free to play with these features, but for the group conversation try to focus on the non-programmatic features.
:::

## NOTES

I'm hoping that this week's tinker will help you implement your design ideas for the project due at the end of the week. The purpose is to 1) provide you with a set of concepts that build on your prior experiences to deepen your understanding and 2) provide you with a practical set of tools that will reduce the development time of your project dramatically.

I recommend that during your discussion, you also address your design ideas for this week's project which I have outlined in the Project Specifications. You can use that as a guide to talk about the important learning design concepts you are considering.

Looking forward to seeing what you come up with. :smile_cat:
