120 likes | 277 Views
CS110: Computers and the Internet. Box Model, Layout. Today. CSS Box Model Using Firebug Layout Centering inline and block elements Float Two-Colum layout. CSS Box Model. p { color: maroon; background-color: pink; width: 200px; padding: 20px;
E N D
CS110: Computers and the Internet Box Model, Layout
Today • CSS Box Model • Using Firebug • Layout • Centering inline and block elements • Float • Two-Colum layout
CSS Box Model p { color: maroon; background-color: pink; width: 200px; padding: 20px; border: 5px dashed blue; margin: 50px; } margin padding width box content border The top, bottom, left and right sides of the margin, padding and border can be styled differently, to create many distinct appearances
Exploring the the Box Model with Firebug • http://cs.wellesley.edu/~cs110/lectures/BoxModel/box-ex1.html
Floats and Flow • By default, blocks on a page, or within another block, are arranged on the page from top to bottom. • The Flow is the normal top-to-bottom mechanism. • Elements can be removed from the flow using the CSS property float • Both inline and block elements can float
CSS Float Example: IntroCS4 • http://cs.wellesley.edu/~cs110/lectures/CSS_example/CSSlayout/introCS4.html • Styled navigation bar • Floating pictures and navigation bar
CSS Two-Columns Example • http://cs.wellesley.edu/~cs110/lectures/CSS_example/CSSlayout/introCS4navleft.html • The border around the navigation bar is removed • Background color of the body is set to the same light blue as the navigation bar • New mainContet Div is create with large enough left margin
CSS Example: Boxes • http://cs.wellesley.edu/~cs110/lectures/CSS_example/CSSlayout/introCSfinal.shtml • This page uses a fixed layout - the navigation bar and block of introductory material both have fixed widths. • A course div surrounds each course description and has a smaller font, narrower width, and is floated to the left • The mainContent div surrounds the four course descriptions and additional course information near the bottom of the page. • Both the mainContent and info div's include clear: both; in their style so that there is a clean separation between these div's and previous page contents. • Finally, some styling for the footer material is placed inside a footer div in the external style sheet.