Bootstrap 4 Drills Covalence
Objectives Practice pulling in Bootstrap 4’s CDN and using its class based styling.
Setup
- Create a new folder for these drills, title it Bootstrap 4 Drills
- Go ahead and initialize a git repository on this project so it will be available to view on your github account.
- Create a README.md file, copy and past these drill instructions into that file.
- Create an index.html page, use the keyboard shortcut to get the html doc started.
- Go to BootStrap website and copy the cdn link and past it in the head of your html document.
- You now have connected the bootstrap cdn to your project and can begin using Bootstrap 4! Hooray.
- Add a styles.css document, link it to your html document AFTER the bootstrap link.
Containers and the Grid System
- Add a div to your html document, using bootstraps container class, have this be a container.
- To visually see what a container class does to a div, we will need to apply some styling to it in css. Let’s go to our css document and apply a background-color of blue and a height of 500px to anything with a class named container (Which for know should only be 1 element).
- Change the class on the div from a container to a container-fluid. Refresh and take not of the differences. Once you are finished visually seeing the difference between the two, remove or comment out the styling in the css file.
- Insert a div inside of the existing container div. Give this div a class name of row, then insert an h1 element inside of the row div. Have the text read “First Boostrap Project”.
- Refer this link on the grid system to learn how rows and alignment work using bootstrap. Lets try to center align our h1, go to the following link to explore how to do so. (Hint: Jump to the horizontal alignment section of bootstraps documents, you may need to adjust the amount of columns, 1 through 12, to keep everything on 1 line).
- Add a new div which will be another row of elements. Add 3 divs, give each some text of your choice and apply bootstrap styling to have 1 div appear at the start of the row, one in the center, and one at the end.
Bootstrap Forms
- Create a form inside of the existing container but outside of any existing rows or other content (ask for help if nesting elements is confusing).
- Have this form contain an input for an email and password. Make sure each input has labels!
- Add 2 checkboxes to the form, one for cats and one for dogs.
- Add 3 radios, have them say Cheese Pizza, Vegetable Pizza, and Meat Pizza
- Make Sure the form has a submit input!
Cards
- Outside of the form but still inside of the container, create a basic card with a card body and have it have an h3 which will be a friends name, and a paragraph element containing a small piece of info on your friend. Create 6 of these cards.
- Have them align so there are 2 per row.
- Once you get them aligning 2 per row, change it so it is 3 per row.