-
Notifications
You must be signed in to change notification settings - Fork 4
Day 6
Matt Enlow edited this page May 13, 2014
·
2 revisions
###900 Code Review! Look at projects from Day 5.
-
widthandheight - avoid % height for now
- total width vs
width
Nothing new to add!
- Margin collapse
- centering with
auto
Make a few boxes, some inside others, setting width, height, margin, border, padding, and background-color (to help visualization)
Floats are our first look into doing actual layouts with our code.
The browser reads, and displays code, line-by-line, top to bottom
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
blockelement, be sure to set itswidthproperty. - 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.
- 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.
The floated elements container may "collapse". We fix that with clear.
clearfix on ....
<br>- subsequent content
Using overflow:auto to prevent parent collapse
Try the br , overflow, and content clearfixes.
Build a website with a left nav.