CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Using CSS for Float Layouts.

Slides:



Advertisements
Similar presentations
15 LAYOUT Controlling the position of elements Creating site layouts Designing for different sized screens.
Advertisements

CSS Layout Crash Course An Advance CSS Tutorial. Inline vs. Block Many HTML elements have a default display setting of Block. Block elements take up the.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Chapter 7 Page Layout Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
INTRODUCTORY Tutorial 7 Creating Liquid Layouts. XP Objectives Discern the differences among various types of layouts Create a liquid layout Create a.
Today’s objectives Site performance Padding, Margins, Borders
Week 9 Using the Box Properties. 9-2 The CSS Visual Formatting Model Describes how the element content boxes should be displayed by the browser –Based.
Tutorial 6 Creating Fixed-Width Layouts
Murach’s ASP.NET 3.5/C#, C5© 2008, Mike Murach & Associates, Inc.Slide 1.
1 Chapter 12 Layout and Positioning Part I of II.
Using CSS for Page Layout. Types of HTML Elements Block-Level Element –Creates blocks of content e.g. div, h1..h6, p, ul, ol, li, table, form –They start.
CSS, cont. October 12, Unit 4. Creating a Sidebar We know how to create a sidebar –Use the float property div#sidebar{ float: left; } Item1 Item2 Item3.
MORE Cascading Style Sheets (The Positioning Model)
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Web Development & Design Foundations with XHTML Chapter 6 Key Concepts.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Advanced CSS - Page Layout. Advanced CSS  Compound Selectors:  Is a Dreamweaver term, not a CSS term.  Describes more advanced types of selectors such.
Principles of Web Design 6 th Edition Chapter 7 – Page Layouts.
ITP 104.  While you can do things like this:  Better to use styles instead:
CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Using the Box Model, & Elements.
Basic Responsive Design Techniques. Let’s take a look at this basic layout. It has a header and two columns of text, in a box that is centered on the.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
1 Cascading Style Sheets (CSS) Part 2. 2 The Sources of Style Sheets.
Copyright © Terry Felke-Morris CSS Flow & Positioning 1 Copyright © Terry Felke-Morris.
CSS Netcentric. What is CSS O CSS stands for Cascading Style Sheets O Styles define how to display HTML elements O Styles were added to HTML 4.0 to solve.
Tutorial #6 – Creating Fixed Width Layouts. Tutorial #5 Review – Box Model Every html element is surround by a box Content, Padding, Border, Margin Can.
CIS234A- Lecture 7 Instructor Greg D’Andrea. Tables A table can be displayed on a Web page either in a text or graphical format. A text table: – contains.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Understanding the Cascade in CSS.
Week 8 – Part 2 Page Layout Basics Key Concepts 1.
Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.
Internet Technology Dr Jing LU Updated Dr Violet Snell / Dr Kalin Penev 1 Internet Technology (week 6)  Recap: Validating HTML  Page Layout.
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
Web Development & Design Foundations with XHTML Chapter 6 Key Concepts.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring 2016 CSS Positioning 1.
Coding with HTML {. THE BASICS { What is HTML and how can you use it to make websites?
- WE’LL LOOK AT THE POSITION PROPERTY AND HOW CSS RESOLVES CONFLICTS BETWEEN STYLING INSTRUCTIONS The position property; CSS specificity hierarchy.
HTML and Dreamweaver November 11th. Agenda Box Model Displaying and positioning elements – Padding – Margin – Float – Display – Position HTML Demo.
Today’s objectives  Announcements  Positioning  Measurement units.
Week 5.  Normal document flow  Affecting document flow with float and position properties using CSS  Using these properties to create layouts.
Nesting and Floating. Nesting and Floating Elements To make our page content appear the way we want, and to make the best use of screen space, we can.
Understanding CSS Cascading Style Sheets control the presentation of content in HTML pages Style Sheets separate formatting from the content –Styles defined.
CS 120: Introduction to Web Programming Lecture 10: Extra Features and Website Design Part 1 Tarik Booker CS 120 California State University, Los Angeles.
CHAPTER 15 Floating and Positioning. FLOAT VS. POSITION  Floating an element moves it to the left or right, allowing the following text to wrap around.
CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Using CSS for Absolute Layouts.
CONCEPTS FOR FLUID LAYOUT Web Page Layout. Essential Questions What challenges do mobile devices present to Web designers? What are the basic concepts.
Mimi Opkins.  One of the major benefits of using CSS is that you’re not forced to lay your sites out in tables.  The layout possibilities of CSS give.
Cascading Style Sheets for layout
Laying out Elements with CSS
Cascading Style Sheets Layout
CSS Layouts: Grouping Elements
Floating & Positioning
Advanced CSS BIS1523 – Lecture 20.
Cascading Style Sheets for layout
Cascading Style Sheets (Layout)
Web Development & Design Foundations with HTML5 7th Edition
Chapter 7 Page Layout Basics Key Concepts
Web Development & Design Foundations with HTML5
The Internet 10/25/11 XHTML Tables
Basics of Web Design Chapter 7 Page Layout Basics Key Concepts
Controlling Layout with Style Sheets
MORE Cascading Style Sheets (The Positioning Model)
Web Development & Design Foundations with H T M L 5
Web Development & Design Foundations with H T M L 5
Web Development & Design Foundations with HTML5
Floating and Positioning
Web Development & Design Foundations with HTML5
Laying out Elements with CSS
Presentation transcript:

CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Using CSS for Float Layouts

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Goals By the end of this lecture, you should understand … … how elements in a web page flow in a normal layout.… how elements in a web page flow in a normal layout. … how block and inline elements flow around floated elements.… how block and inline elements flow around floated elements. … how to build a Liquid Layout.… how to build a Liquid Layout. … how to build a Frozen Layout.… how to build a Frozen Layout. … how to build a Jello Layout.… how to build a Jello Layout.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science What is Flow? Flow describes the way in which the browser positions elements in a web page.Flow describes the way in which the browser positions elements in a web page. The browser positions block elements on top of one another, with a blank line between them. Block elements never give up their vertical position as a browser resizes.The browser positions block elements on top of one another, with a blank line between them. Block elements never give up their vertical position as a browser resizes. The browser positions inline elements right to left. As the browser collapses, it will re- position inline elements on new lines, as needed.The browser positions inline elements right to left. As the browser collapses, it will re- position inline elements on new lines, as needed.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Flow & Margins When two inline elements are side by side, the flow of the web page will respect each element's margin.When two inline elements are side by side, the flow of the web page will respect each element's margin. However, when we place two block elements on top of one another (or side by side), the flow will collapse the smallest of the two margins. The two elements will share the largest margin.However, when we place two block elements on top of one another (or side by side), the flow will collapse the smallest of the two margins. The two elements will share the largest margin.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Flow & Nested Block Elements When we nest a block element inside another, flow will still collapse the smallest margin.When we nest a block element inside another, flow will still collapse the smallest margin. However, if either of the elements has a border, the margins remain intact.However, if either of the elements has a border, the margins remain intact. Why? The margins don't touch one another.Why? The margins don't touch one another.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Floating an Element The float property "takes an element and floats it as far left or right as it can."The float property "takes an element and floats it as far left or right as it can." To float an element:To float an element: 1.Give the element an identity (id). 2.Give the element a width. 3.Move the element's code directly below the element under which you want the floated element to appear. 4.Add a float property to element's style.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Float … the Browser's View The browser renders elements using flow, from top to bottom.The browser renders elements using flow, from top to bottom. When the browser encounters a floated element, it removes that element from the flow of the page.When the browser encounters a floated element, it removes that element from the flow of the page. Since the browser removes the floated element from the normal flow, block elements "fill in" behind the floated element.Since the browser removes the floated element from the normal flow, block elements "fill in" behind the floated element. continued …

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Float … the Browser's View The block level elements ignore the floated element's borders.The block level elements ignore the floated element's borders. However, the inline elements (text, images, etc) contained in those block elements respect the floated element's borders and flow around it.However, the inline elements (text, images, etc) contained in those block elements respect the floated element's borders and flow around it.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Let's Try One! Download and expand the file " n241AdvPageLayoutFloat_Examples.zip."Download and expand the file " n241AdvPageLayoutFloat_Examples.zip." Examine the file " Head First Lounge/lounge.html."Examine the file " Head First Lounge/lounge.html." Move the elixirs below the music recommendations and then save and view the file. Where did it position?Move the elixirs below the music recommendations and then save and view the file. Where did it position? Now, move the elixirs back, turn off styles and then check it out!Now, move the elixirs back, turn off styles and then check it out!

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Let's Try Another Edit the " Starbuzz/index.html " file. Move the sidebar just below the header.Edit the " Starbuzz/index.html " file. Move the sidebar just below the header. Now, edit " Starbuzz/css/starbuzz.css " by adding the following declarations to the #sidebar rule: width : 280px; float: right;Now, edit " Starbuzz/css/starbuzz.css " by adding the following declarations to the #sidebar rule: width : 280px; float: right;

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Defining a Boundary Between Columns Right now the Starbuzz page looks as if the backgrounds of the main and the sidebar blend with each other.Right now the Starbuzz page looks as if the backgrounds of the main and the sidebar blend with each other. How can we fix this? We need to redefine the right margin of the main at least as large as the width of the sidebar. Edit the following declaration in the #main rule: margin: 0px 330px 10px 10px;How can we fix this? We need to redefine the right margin of the main at least as large as the width of the sidebar. Edit the following declaration in the #main rule: margin: 0px 330px 10px 10px;

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science The Overlap Problem With wider resolutions, the sidebar might overlap the footer due to the flow of the block elements.With wider resolutions, the sidebar might overlap the footer due to the flow of the block elements. How can we fix this? We can add a clear property to the footer …How can we fix this? We can add a clear property to the footer …

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science The clear Property With the clear property, we can specify that no floating content may be on the right, left or both sides of an element.With the clear property, we can specify that no floating content may be on the right, left or both sides of an element. Find the #footer class and add the following declaration: clear: right;Find the #footer class and add the following declaration: clear: right;

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Looks Good So Far, But … Try turning off the CSS for the Starbuzz page. What are the problems?Try turning off the CSS for the Starbuzz page. What are the problems? Let's try swapping the sidebar with the main.Let's try swapping the sidebar with the main. Then make the changes to your CSS depicted in the next few slides …Then make the changes to your CSS depicted in the next few slides …

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Adjusting #sidebar Delete the width & float declarations from the #sidebar class.Delete the width & float declarations from the #sidebar class. Edit the margin declaration to look like this: margin: 0px 10px 10px 470px;Edit the margin declaration to look like this: margin: 0px 10px 10px 470px;

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Adjusting #main & #footer In the #main rule, edit the margin declaration to look like this: margin: 0px 10px 10px 10px;In the #main rule, edit the margin declaration to look like this: margin: 0px 10px 10px 10px; Add the following declarations to the #main rule: width: 420px; float: left;Add the following declarations to the #main rule: width: 420px; float: left; Change the clear property of the #footer rule to read: clear: left;Change the clear property of the #footer rule to read: clear: left;

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Liquid Layouts So far, we've been working with liquid layouts. Liquid layouts fill whatever width is left when the browser resizes.So far, we've been working with liquid layouts. Liquid layouts fill whatever width is left when the browser resizes. Liquid layouts make good use of their screen space but might now always fit our needs for our layout looking generally the same on different sized browsers.Liquid layouts make good use of their screen space but might now always fit our needs for our layout looking generally the same on different sized browsers.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Frozen Layouts Frozen layouts "lock" elements into place, so they appear frozen to the page.Frozen layouts "lock" elements into place, so they appear frozen to the page. Frozen layouts allow us to keep elements from expanding as a browser window changes in size.Frozen layouts allow us to keep elements from expanding as a browser window changes in size. Let's try one …Let's try one …

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science First, the XHTML side … In your index.html, add the following div, nesting everything else in the page (except for the tag): … In your index.html, add the following div, nesting everything else in the page (except for the tag): …

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Now for the CSS … Add the following rule to your starbuzz.css file: #allcontent { width: 800px; padding-top: 5px; padding-bottom: 5px; background-color: #675C47; }Add the following rule to your starbuzz.css file: #allcontent { width: 800px; padding-top: 5px; padding-bottom: 5px; background-color: #675C47; }

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Almost there … The Frozen Layout is an improvement over the Liquid Layout, but how can we fix the large gap on the right side when the browser is very wide?The Frozen Layout is an improvement over the Liquid Layout, but how can we fix the large gap on the right side when the browser is very wide? The Jello Layout to the rescue …The Jello Layout to the rescue …

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Making Jello Add the following declarations to the #allcontent class: margin-left: auto; margin-right: auto;Add the following declarations to the #allcontent class: margin-left: auto; margin-right: auto;

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Next Time … We'll discuss another approach to layouts using absolute positioning.We'll discuss another approach to layouts using absolute positioning.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Questions?

References Freeman, Elisabeth and Eric Freeman. Head First HTML with CSS & XHTML. Sebastopol, CA: 2006.Freeman, Elisabeth and Eric Freeman. Head First HTML with CSS & XHTML. Sebastopol, CA: Neiderst-Robbins, Jennifer. Web Design in a Nutshell, Third Edition. Sebastopol, CA: 2006.Neiderst-Robbins, Jennifer. Web Design in a Nutshell, Third Edition. Sebastopol, CA: 2006.