CA 272 - Professional Web Site Development CSS Positioning.

Slides:



Advertisements
Similar presentations
LIS650 lecture 4 Thomas Krichel today CSS Properties –Box properties-- List properties –Table properties-- Classification properties –(Audio.
Advertisements

Week 10 Creating Positioned Layouts
15 LAYOUT Controlling the position of elements Creating site layouts Designing for different sized screens.
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.
Part 5 Introduction to CSS. CSS Display - Block and Inline Elements A block element is an element that takes up the full width available, and has a line.
CIS 1310 – HTML & CSS 6 Layout. CIS 1310 – HTML & CSS Learning Outcomes  Describe & Apply the CSS Box Model  Configure Float with CSS  Designate Positioning.
Tutorial 4: Creating page layout with css
Ch. 6 Web Page Design – Absolute Positioning, Image Maps, and Navigation Bars Mr. Ursone.
Web-based Application Development Lecture 9 February 7, 2006 Anita Raja.
MORE Cascading Style Sheets (The Positioning Model)
Page Layout & Mobile Web Using columns, grid systems, etc… to layout sites for desktops and mobile.
Advanced CSS - Page Layout. Advanced CSS  Compound Selectors:  Is a Dreamweaver term, not a CSS term.  Describes more advanced types of selectors such.
CA Professional Web Site Development Class 23 - CSS Positioning, Image Replacement & Print Styles.
Tutorial 4: Using CSS for Page Layout. 2 Objectives Session 4.1 Explore CSS layout Compare types of floating layouts Examine code for CSS layouts View.
Cascading Style Sheets CSS. CSS Positioning Normal Flow Top -> bottom | left -> right Arranged in the order they appear in the code make room for one.
Cascading Style Sheets CSS. div … Used like a container to group content Gives context to the elements in the grouping Give it a descriptive name with.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
The Missing Manual MARGINS, PADDING, & BORDERS—CHAPTER 7.
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.
Page Layout with CSS Learning Web Design: Chapter 16.
 Website development process  CSS  Javascript.
CSS = Cascading Style Sheet CSS consists of rules to display, style and decorate HTML elements Why CSS ? – Separate decoration from HTML markup (Ex :,,…)
CSCE 102 – Chapter 6 (Web Design and Layout) CSCE General Applications Programming Benito Mendoza Benito Mendoza 1 By Benito Mendoza.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
Week 8 – Part 2 Page Layout Basics Key Concepts 1.
THE BOX MODEL Putting layouts together with CSS. The Box Model  How would you describe a box?  Container?  Tags or elements are “containers”  puts.
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.
Cascading Style Sheets Positioning Controls Visibility.
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
Cascading Style Sheets Positioning Controls Visibility.
CONTROLLING Page layout
Tutorial 4 Creating Page Layouts with CSS
Positioning Objects with CSS and Tables
- WE’LL LOOK AT THE POSITION PROPERTY AND HOW CSS RESOLVES CONFLICTS BETWEEN STYLING INSTRUCTIONS The position property; CSS specificity hierarchy.
Today’s objectives  Announcements  Positioning  Measurement units.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 6 1 Creating Dynamic Pages.
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.
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.
Tutorial 4 Using CSS for Page Layout. Objectives Session 4.1 – Explore CSS layout – Compare types of floating layouts – Examine code for CSS layouts –
Laying out Elements with CSS
Cascading Style Sheets Layout
CSS Layouts: Grouping Elements
Webpage layout using CSS
Cascading Style Sheets
Positioning Objects with CSS and Tables
Floating & Positioning
Advanced CSS BIS1523 – Lecture 20.
Putting Things Where We Want Them
Web Development & Design Foundations with HTML5 7th Edition
Chapter 7 Page Layout Basics Key Concepts
Basics of Web Design Chapter 7 Page Layout Basics Key Concepts
Objectives Create a reset style sheet Explore page layout designs
Controlling Layout with Style Sheets
Positioning.
MORE Cascading Style Sheets (The Positioning Model)
Tutorial 6 Creating Dynamic Pages
HTML – Organizing Page Content
HTML – Organizing Page Content
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
Cascading Style Sheets
Web Development & Design Foundations with H T M L 5
Floating and Positioning
Positioning.
Positioning.
Laying out Elements with CSS
The div Element and CSS for layout
Positioning Objects with CSS and Tables
Presentation transcript:

CA Professional Web Site Development CSS Positioning

Announcements CA/CS Advising Day in Faculty Dining Room: Wed., 11/28 from 3:00 to 6:30 p.m. I am speaking with Prof. Lizmi’s ColdFusion class about the Web design/development business: Wed., 11/28 at 6:00 p.m., HU 313

Review - Positioning Schemes 1. Static - a.k.a. ‘normal flow’ 2. Relative - offset by some value 3. Absolute - positioned at specified coordinates outside normal flow 4. Fixed - positioned to viewport 5. (Float - displaces text only)

Static Positioning Normal flow - not ‘positioned’ Block-level elements generate an (invisible) box Elements ‘flow’ one after another; elements are displaced by previous elements in code Elements cannot appear side by side One-column layout

Relative Positioning  Element is offset by some value (relative to original position)  Element retains shape it would have had in normal flow  Normal flow preserves space originally taken up by element  Element may overlap other elements  Good for establishing positioning context

Relative Positioning Example: relative positioned div Exercise: relative positioned span Open blank HTML document Insert a few paragraphs of text Wrap (CTRL-T) some text in … Create style rule for span with positioning type ‘relative’ and some offset values

Absolute Positioning Element is completely removed from normal flow (and space it occupied disappears) Placement is specified by offset values (relative to containing block) Always generates block-level box Absolutely positioned elements do not interact with each other (except for stacking order) Must know exact coordinates to position elements See example

Fixed Positioning Just like Absolute Positioning, except… Elements positioned relative to viewport (browser window) - scrolling window does not affect element Good for frame-like layouts IE 6 and under do not support fixed positioning See example

Floats (Not actually a positioning scheme - elements can be floated AND positioned) Elements removed from normal flow… EXCEPT floated elements displace text in normal flow (but NOTHING ELSE) Floated elements displace other floated elements! Margins on floats do not collapse Use clear: left | right | both; on OTHER elements to keep them from being beside a floated element

Positioning Context - the Containing Block Containing block determines where positioned element is placed For static and relative positioning, containing block is nearest block-level, table cell or inline box parent

Positioning Context (continued) For absolute positioning, containing block is nearest positioned element (relative, absolute or fixed) Default positioning context is element (document window) For fixed positioning, containing block is viewport

Offset Values Top, Bottom, Right, Left Units: length (px) or percentage (%) Offset values are relative to containing block Positive values move element inward (relative to containing block) Negative values move element outwards % values are relative to height and width of containing block Should give top or bottom AND side value Default is top: 0; left: 0;

Stacking Order: z-index Elements can be positioned 3-dimensionally along the z axis using z-index (only ‘positioned’ elements) Higher values of z-index are further on top z-index can be negative Normal flow elements are z-index: 0; Local stacking context

Other Layout Properties Width/Height - important for constraining size of layout elements >> Floated elements MUST have width specified Display: block; - when we want inline element to behave as block element (e.g., anchor as button) Overflow: visible | hidden | scroll Max-width/max-height & min-width/min-height >> very useful for liquid layouts Unsupported by older versions of IE

Exercise: Absolute Positioning Open a blank HTML document in DW Go to the Layout tab in the Insert Bar Draw some boxes in Design View (these will be absolutely positioned divs) Go to Code View and view the CSS position: absolute; left; top; width; height; z- index

Exercise: Absolute Positioning (continued) Click on one of your divs and add some text; make text a paragraph Click on AP div ‘handle’ to select it Delete height value in Property Inspector You can change left, top, width, height (also drag with handle and bounding box)

Exercise: Absolute Positioning (continued) Set background color on divs Drag one div to overlap another Change z-index values (set lowest one to highest value) Select overlapping div and Edit > Cut Click in other div and Edit > Paste Why is div in different place?

Exercise: Absolute Positioning (continued) Insert several paragraphs of text in an AP div (e.g., from lipsum.com) Select div and set height (to value smaller than height of text) - view change Set overflow to hidden - view change Set overflow to scroll; preview in browser

Web Layout Patterns Common elements in Web layouts: Branding & Marketing Navigation (main nav, page nav, etc.) Primary content (often text content) Supplemental content (sidebars, calls to action, ads, images, etc.) Footer content and site tools

Review: Page Layout Schemes Fixed width - width set to fixed px value Most designers use fixed width because easiest to design for PRO: easier to design graphics for, can set readable line lengths of text CON: doesn’t take advantage of screen width for users with large monitors; users with smaller monitors may have to scroll horizontally

Page Layout Dimensions Fixed design for pixel widths - must account for browser ‘chrome’, scrollbars 800 x 600 monitor: 750px (or 760px) width Safest width, but only 12% of users 1024 x 800 monitor: 950px+ width Most users have this resolution now (53%) 1280 x 1024 is gaining (~23%) Don’t worry about 640 x 480 anymore

Page Layout Schemes Fluid/Liquid - width set to % value, adjusts to width of browser window PRO: makes full use of browser window; user can resize CON: may lead to very long lines of text; harder to design for See:

Page Layout Schemes Elastic - width set in relative units (ems) Page elements grow proportionately as user resizes text size PRO: ideal for accessibility - users can view at whatever scale is comfortable for them CON: very difficult to code; can lead to very large widths as user increases font size Rarely used

Web Layouts Examples:

Web Layout Patterns

CSS Layouts with Floats and Positioning Review: two-column float with clearing footer Wrapper encloses everything Each column is floated Footer clears floats and extends wrapper Column backgrounds are on #wrapper

CSS Layouts with Absolute Positioning Can replicate layout with AP divs BUT, must know placement of all divs How do you place footer if variable content? How do you create column backgrounds for unknown height?

CSS Layouts with AP - continued Absolute positioning is useful for positioning elements WITHIN layouts E.g., masthead graphics See “liquid layout” (linked on class homepage)

CSS Image Replacement What if we want to replace text with a graphic? (using CSS only) Should leave text in HTML for accessibility and SEO Many techniques; most common (probably) is ‘Phark’ method: text-indent: -5000px; e.g. h1#logo { text-indent: -5000px; background: url(logo.gif) 0 0 no-repeat; width and height as needed } Coca-Cola

CSS Image Replacement Downsides: If images are turned off (but CSS is on) nothing will display Background images usually do not print If you edit text, you’ll need to edit the graphic

Exercise: Image Replacement Download from the class site: Float layout (save to homework folder) Nav button background image (save to images folder) Join button jpeg (save to images folder) Insert a link, “Join Today!”, at the beginning of the second paragraph of simple-page- layout4a.html Give this link class ‘joinButton’

Exercise: Image Replacement (continued) Create CSS styles (for default state and :hover) to make link a button with join.jpg as background image (button should be 100px by 100px) (display; width; height; background; etc.) Float button right and add left and bottom margins Preview in browser Need to hide text of link: text-indent: -5000px; Preview in Firefox - click and hold down button should see dotted box off to left Add outline: none; and preview again

Homework Rework homework 16 to float both left and right columns, using wrapper div and clearing footer Create a third column inside div#rtCol Read Chapters 8 & 14 in the Visual QuickStart Guide