140 likes | 344 Views
CSS Positioning. WRA 210 11.4.13. Today’s Agenda. Review: <div> and CSS Box Model Review: HTML5 structural objects Intro: CSS float property for positioning Activity: use float to fully position your layout Activity: Begin to style your pages as they look in your design docs.
E N D
CSS Positioning WRA 210 11.4.13
Today’sAgenda • Review: <div> and CSS Box Model • Review: HTML5 structural objects • Intro: CSS float property for positioning • Activity: use float to fully position your layout • Activity: Begin to style your pages as they look in your design docs
The CSS Box Model • All objects are part of the box model (not just <div>) • margin: space outside the border, between objects • border: perimeter, boundaries • padding: space inside border, between content • height, width: space between padding • control single sides of a box or all sides at once
Example <div> object <div id="header"> <h1>This is My Cool Website</h1> <ul id="navigation"> <li><a href="index.html">Home</a></li> <li><a href="about.html">About Me</a></li> <li><a href="resume.htm">Resume</a></li> </ul> </div><!-- #header -->
DIVs vs HTML5 Structural Objects Structural Markup in HTML4 Structural Markup in HTML5
Tonight: CSS Float • Where we start to lose our semanticness • Cheating at the box model • Positioning objects • Weirdness • Activity: use floats to begin positioning your structural markup
ThinkBack: The "Inverted L" • Remember? • Built our structure, shaped with widths • Why do "nav" and "content" need altering?
Behavior of Objects in Box Model • By default, objects take 100% width of parent • Even with fixed width, objects take up 100% of horizontal plane • By default, objects are defined by their top and bottom boundaries • Translation: we cannot have objects positioned next to one another. Unless ...
What does float do to an object? • Allows content of other objects to wrap • paragraph text, header text, links, etc • Makes its borders invisible to other objects • objects will overlap if not contained properly • Makes possible: • text wrap around images • multi-column designs
Short Activity 1: test float • Go to Thimble • Create 4 paragraphs • Add an image above the first paragraph, use this url: http://cosmicmonkeycomics.com/AaronRenierThumb.jpg • Add style attribute to image tag • Apply style "float:left"; • Change style to "float:right";
Short Activity 2: recreate Inverted L • Download and open source file • Discuss: what's happening with structure? • Size and position stable objects • container, header, footer • Experiment with float on nav and content • The importance of the overflow style in containing floated objects
Long Activity: Style Your Structures • If you haven't already, begin applying widths to your container objects (assuming 960px) • Start using floats for positioning • More about multi-column layouts (if needed): • Two-column layouts • Three-column layouts • Think about containers and overflow
For Next Time • Continue to develop CSS, position structure • CSS and Color • CSS Backgrounds - About and Tutorial • CSS Images (explore the entire site) • CSS font properties • CSS web-safe fonts (reminder)