How to use CSS for page layout Murach's HTML and CSS, 4th Edition

Slides:



Advertisements
Similar presentations
HTML and CSS. HTML Hyper Text Markup Language Tells browser how to display text and images.
Advertisements

Cascading Style Sheets
Chapter 6 More CSS Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Layout using CSS. Using multiple classes In the head:.important{font-style:italic;}.title{color:red;} In the body: Here's a type of paragraph that is.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Murach's PHP and MySQL, C1© 2010, Mike Murach & Associates, Inc.Slide 1.
Slide 1 CMPS 211 Internet Programming Spring 2008 Dynamic Effects with Styles Chapter 12 2/6/08.
Chapter 7 Page Layout Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
Very quick intro HTML and CSS. Sample html A Web Title.
Web Development & Design Foundations with XHTML Chapter 7 Key Concepts.
Cascading Style Sheets By: Valerie Kuna. What are Cascading Style Sheets? Cascading Style Sheets (CSS) are a standard for specifying the presentation.
Session 4: CSS Positioning Fall 2006 LIS Web Team.
Web Development & Design Foundations with XHTML Chapter 7 Key Concepts.
Advance CSS (Menu and Layout) Miftahul Huda. CSS Navigation MENU It's truly remarkable what can be achieved through CSS, especially with navigation menus.
CIS 1310 – HTML & CSS 6 Layout. CIS 1310 – HTML & CSS Learning Outcomes  Describe & Apply the CSS Box Model  Configure Float with CSS  Designate Positioning.
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
Diliev.com & pLOVEdiv.com  DIliev.com.
Class four: the box model and positioning. is an HTML tag which allows you to create an element out of inline text. It doesn’t mean anything! try it:
Unit 20 - Client Side Customisation of Web Pages
Tutorial 4: Creating page layout with css
Tutorial 6 Creating Fixed-Width Layouts
ITI 133: HTML5 Desktop and Mobile Level I
Principles of Web Design 6 th Edition Chapter 10 – Data Tables.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
WEB DEVELOPMENT IMMERSIVE BUILDING PAGE LAYOUTS. 2 Box Model Scaling Positioning Boxes Box Aesthetics HTML 5 Semantic Tags CSS Resets TOPICS GENERAL ASSEMBLYWEB.
Internet Technology Dr Jing LU Updated Dr Violet Snell / Dr Kalin Penev 1 Internet Technology (week 6)  Recap: Validating HTML  Page Layout.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
WebD Introduction to CSS By Manik Rastogi.
Laying out Elements with CSS
Web Development & Design Foundations with HTML5 7th Edition
4.01 Cascading Style Sheets
Creating Your Own Webpage
Webpage layout using CSS
Creating Page Layouts with CSS
Cascading Style Sheets (Layout)
HTML5 Level I Session II Chapter 2 - How to Code, Test and Validate a Web Page
Web Development & Design Foundations with HTML5 7th Edition
Chapter 7 Page Layout Basics Key Concepts
Web Development & Design Foundations with HTML5 8th Edition
Web Development & Design Foundations with HTML5
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Chapter 6 More CSS Basics Key Concepts
ITI 133 HTML5 Desktop and Mobile Level I
HTML5 Level I Session III
Basics of Web Design Chapter 7 Page Layout Basics Key Concepts
CS 174: Server-Side Web Programming February 7 Class Meeting
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
The Internet 10/13/11 The Box Model
Fixed Positioning.
HTML5 Session III Chapter 5 - How to Use the CSS Box Model for Spacing, Borders, and Backgrounds Chapter 6 - How to use CSS for page.
Box model, spacing, borders, backgrounds
Cascading Style Sheets
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
CMPE 280 Web UI Design and Development September 4 Class Meeting
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
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
How to use the CSS box model for spacing, borders, and backgrounds
ITI 133: HTML5 Desktop and Mobile Level I
How to use CSS to format the elements of a web page
CMPE 280 Web UI Design and Development February 7 Class Meeting
How to code, test, and validate a web page
Web Development & Design Foundations with HTML5
Principles of Web Design 5th Edition
4.01 Cascading Style Sheets
Session IV Chapter 15 - How Work with Fonts and Printing
CMPE 280 Web UI Design and Development September 5 Class Meeting
Presentation transcript:

How to use CSS for page layout Murach's HTML and CSS, 4th Edition Chapter 6 How to use CSS for page layout © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

Murach's HTML and CSS, 4th Edition Objectives Applied Given an HTML document, create a CSS style sheet that uses floating to implement a fixed or fluid page layout in two- or three-column format with both header and footer. Knowledge Describe the use of floating for page layout. Describe the use of the clear property in a CSS rule set. Distinguish between fixed and fluid page layout. Describe the use of the CSS3 feature for text columns. Describe the use of absolute, relative, and fixed positioning. © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The HTML for a web page with a sidebar <body> <aside> <p>The luncheon starts 15 minutes after the lecture ends</p> </aside> <main> <p>Welcome to San Joaquin Valley Town Hall. We have some fascinating speakers for you this season!</p> </main> <footer> <p>Please call today at (559) 555-1212 to get your tickets!</p> </footer> </body> © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for floating the sidebar body { width: 500px; } main, aside, footer { margin: 0; padding: 0px 20px; } aside { margin: 0 20px 10px; width: 150px; float: right; border: 1px solid black; } footer { clear: both; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The web page with the side bar in a browser © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

A 2-column web page with fixed-width columns © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The HTML for the 2-column, fixed-width page <body> <header> <h2>Header</h2> </header> <main> <h2>Main content</h2> </main> <aside> <h2>Aside</h2> </aside> <footer> <h2>Footer</h2> </footer> </body> © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the 2-column, fixed-width page * { margin: 0; padding: 0; } body { width: 962px; background-color: white; margin: 15px auto; border: 1px solid black; } h2 { padding: 1em; }   header { border-bottom: 2px solid #ef9c00; } main { height: 350px; /* to give the sidebar some height for its border */ width: 600px; float: left; border-right: 2px solid #ef9c00; } aside { width: 360px; float: right; } footer { clear: both; border-top: 2px solid #ef9c00; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

A 2-column page with fluid column widths © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the 2-column, fluid page body { width: 90%; background-color: white; margin: 15px auto; border: 1px solid black; } main { width: 66%; height: 350px; /* to give the main content some height */ border-right: 2px solid #ef9c00; float: left; } aside { width: 33%; float: right; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS when the aside is fixed and the section is fluid body { width: 90%; background-color: white; margin: 15px auto; border: 1px solid black; } main { float: left; } aside { height: 350px; /* to give the aside some height */ width: 360px; border-left: 2px solid #ef9c00; float: right; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

A 3-column page with fixed-width columns © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The HTML for the 3-column page <body> <header> <h2>Header</h2> </header> <aside id="sidebarA"> <h2>Sidebar A</h2> </aside> <main> <h2>Main content</h2> </main> <aside id="sidebarB"> <h2>Sidebar B</h2> <footer> <h2>Footer</h2> </footer> </body> © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the 3-column, fixed-width page body { width: 964px; background-color: white; margin: 15px auto; border: 1px solid black; } #sidebarA { width: 180px; height: 350px; /* to give the sidebar some height for its border */ float: left; border-right: 2px solid #ef9c00; } main { width: 600px; float: left; } #sidebarB { float: right; border-left: 2px solid #ef9c00; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

A home page with a sidebar floated to the right © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The HTML for the home page (part 1) <head> . <link rel="stylesheet" href="styles/normalize.css"> <link rel="stylesheet" href="styles/main.css"> </head> <body> <header> <img src="images/logo.jpg" alt="Town Hall Logo" width="80"> <h2>San Joaquin Valley Town Hall</h2> <h3>Bringing cutting-edge speakers to the valley</h3> </header> <main> <aside> <h2>Lecture notes</h2> <h3>Event change for November</h3> © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The HTML for the home page (part 2) <p>SJV Town Hall is pleased to announce the addition of award-winning author Andrew Ross Sorkin. The appearance of previously scheduled speaker, Greg Mortenson, has been postponed.</p> <h3>Lecture day, time, and location</h3> <p class="news_item">All one-hour lectures are on the second Wednesday of the month beginning at 10:30 a.m. at William Saroyan Theatre, 700 M Street, Fresno, CA.</p> </aside> © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The HTML for the home page (part 3) <section> <h1>This season's guest speakers</h1> <nav> <ul> <li>October: <a class="date_passed" href="speakers/toobin.html">Jeffrey Toobin</a></li> . <li>March: <a href="speakers/eire.html"> Carlos Eire</a></li> <li>April: <a href="speakers/tynan.html"> Ronan Tynan</a></li> </ul> </nav> <h2>Looking for a unique gift?</h2> © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The HTML for the home page (part 4) <p>Town Hall has the answer. For only $100, you can get a book of tickets for all of the remaining speakers. And the bargain includes a second book of tickets for a companion.</p> <p>Or, for $50, you can give yourself the gift of our speakers, and still get an extra ticket for a companion, but for just one of the events.</p> <p>See you at the next show?</p> <p id="contact_us"><em>Contact us by phone</em> at (559) 555-1212 for ticket information.</p> </section> </main> <footer> <p>© Copyright 2018 San Joaquin Valley Town Hall.</p> </footer> </body> </html> © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the home page (part 1) /* type selectors */ html { background-image: -moz-linear-gradient( to bottom, white 0%, #facd8a 100%); background-image: -webkit-linear-gradient( to bottom, white 0%, #facd8a 100%); background-image: -o-linear-gradient( to bottom, white 0%, #facd8a 100%); background-image: linear-gradient( to bottom, white 0%, #facd8a 100%); } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 100%; width: 990px; background-color: white; margin: 15px auto; padding: 15px 0; border: 1px solid black; } /* no border radius or box shadow */ © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the home page (part 2) section, aside, h1, h2, h3, p { margin: 0; padding: 0; } section, aside { margin-top: 1.5em; margin-bottom: 1em; }   a { font-weight: bold; } a:link { color: #931420; } a:visited { color: #f2972e; } a:hover, a:focus { color: blue; } ul { margin-top: 0; margin-bottom: 1.5em; } li { font-size: 95%; padding-bottom: .35em; } p { padding-bottom: .5em; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the home page (part 3) em { font-weight: bold; }   /* the styles for the header */ header { padding-bottom: 2em; border-bottom: 2px solid #f2972e; } header img { float: left; margin-left: 20px; } header h2 { font-size: 220%; color: #f2972e; text-shadow: 2px 3px 0 black; margin-left: 120px; margin-bottom:.25em; } header h3 { font-size: 130%; font-style: italic; margin-left: 120px; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the home page (part 4) /* the styles for the section */ section { width: 535px; margin-left: 20px; padding-right: 25px; float: right; } section h1 { font-size: 170%; margin-bottom: .35em; } section h2 { font-size: 130%;   #contact_us { margin-top: 1em; } a.date_passed { color: gray; } /* the styles for the sidebar */ © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the home page (part 5) aside { width: 350px; float: right; padding: 20px; background-color: #ffebc6; margin-right: 20px; } aside h2 { font-size: 130%; padding-bottom: .5em; } aside h3 { font-size: 100%; color: #931420; aside p { margin-bottom: .5em; }   /* the styles for the footer */ footer { clear: both; border-top: 2px solid #f2972e; padding-top: .7em; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the home page (part 6) footer p { font-size: 80%; text-align: right; margin-right: 20px; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

A speaker page with a sidebar on the right © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The HTML for the speaker page (part 1) <head> ... <link rel="stylesheet" href="styles/speaker.css"> </head> <aside> <h2>This season's guest speakers</h2> <nav> <ul> <li>October: <a class="date_passed" href="speakers/toobin.html">Jeffrey Toobin</a></li> . <li>April: <a href="speakers/tynan.html">Ronan Tynan</a></li> </ul> <p><a href="index.html">Return to Home page</a></p> </nav> </aside> © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The HTML for the speaker page (part 2) <article> <h1>Fossil Threads in the Web of Life</h1> <img src="images/sampson_dinosaur.jpg" alt="Scott Sampson" width="260"> <p>What's 75 million years old and brand spanking new? A teenage ... ...</p> <p>Scott Sampson is a Canadian-born paleontologist who received his <p>Following graduation in 1993, Sampson spent a year working at the <p>In addition to his museum and laboratory-based studies, Sampson has </article> © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the speaker page article, aside, h1, h2, p, ul { margin: 0; padding: 0; } article, aside { margin-top: 1.5em; margin-bottom: 1em; }   /* the styles for the article */ article { width: 535px; margin-left: 20px; padding-right: 25px; float: right; } article h1 { font-size: 170%; margin-bottom: .35em; } article img { float: left; margin: 0 1.5em 1em 0; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The primary CSS3 properties for creating text columns column-count column-gap column-rule column-span 3 columns with default-sized gaps article { column-count: 3; } 3 columns with 35px gaps and 2px rules between the columns column-count: 3; column-column-gap: 35px; column-rule: 2px solid black; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

3 columns with 35px gaps and 2px rules in a browser window © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

A web page with a two-column article © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for creating the columns article { column-count: 2; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

Properties for positioning elements top, bottom, left, right z-index Possible values for the position property static absolute fixed relative © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The HTML for a web page that will use positioning <body> <main> <h1>Our speakers this season</h1> <ul> <li>October: <a href="speakers/toobin.html"> Jeffrey Toobin</a></li> <li>November: <a href="speakers/sorkin.html"> Andrew Ross Sorkin</a></li> <li>January: <a href="speakers/chua.html"> Amy Chua</a></li> </ul> <p>Please contact us for tickets.</p> </main> <aside> <p><a href="raffle.html">Enter to win a free ticket!</a></p> </aside> </body> © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the web page with absolute positioning p { margin: 0;} body { width: 550px; margin: 0 25px 20px; border: 1px solid black; position: relative; } /* not needed for fixed positioning */ aside { width: 80px; padding: 1em; position: absolute; /* change to fixed for fixed positioning */ right: 30px; top: 50px; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The web page with absolute positioning in a browser © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

A sidebar that uses fixed positioning This may not be covered in 3rd edition. © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

The CSS for the positioned element aside { width: 350px; padding: 20px; background-color: #ffebc6; position: fixed; right: 0; top: 170px; } © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

Short 6-1 Use the CSS3 columns feature © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

Short 6-2 Switch the columns of a page © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition

Short 6-3 Add a third column to a page © 2018, Mike Murach & Associates, Inc. Murach's HTML and CSS, 4th Edition