Day 6 - PitchEngine/code-wyoming GitHub Wiki
Itinerary
###900 Code Review! Look at projects from Day 5.
1300
The Box Model
Content Box
width
andheight
- avoid % height for now
- total width vs
width
Padding, Border
Nothing new to add!
Margin
- Margin collapse
- centering with
auto
Boxes Project
Make a few boxes, some inside others, setting width, height, margin, border, padding, and background-color (to help visualization)
1430
Floating
Floats are our first look into doing actual layouts with our code.
Normal flow
The browser reads, and displays code, line-by-line, top to bottom
Float
The float
property takes none | left | right
values.
A floated element...
- Render's in normal flow order
- Shifts as far left or right as possible within its container
- When floating a
block
element, be sure to set itswidth
property. - Elements after the floated element will "bubble" up and around it.
- Margin is useful to push the "bubbled up" elements away from the floated element.
Project!
- Create a new file
- Create a div with
id="wrapper"
in your body. We'll use this div to center everything - Place an H1 with text "Learning About Floats" inside of the #wrapper div.
- Place an image with
src="//placekitten.com/200/400"
after the H1. - Put a paragraph with two sentences worth of text after the img.
- Center your wrapper with a width of 640px.
- Look at your handiwork, and observe normal flow.
- Create the following classes in your css
.float-left {
float: left;
}
.float-right {
float: right;
}
Alternate putting float-left
and float-right
on your image and see what happens.
Clear
The floated elements container may "collapse". We fix that with clear
.
clearfix
on ....
<br>
- subsequent content
Using overflow:auto to prevent parent collapse
Project
Try the br , overflow, and content clearfixes.
Homework
Build a website with a left nav.