CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.

Slides:



Advertisements
Similar presentations
Copenhagen, 6 December 2004 Modern CSS Principles Miruna Bădescu Finsiel Romania.
Advertisements

1 Cascading Style Sheets Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
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.
Creating Special Effects with CSS
Working with Cascading Style Sheets
Tutorial 6 Creating Fixed-Width Layouts
TUTORIAL 4: CREATING PAGE LAYOUT WITH CSS Session 4.3.
Cascading Style Sheets Controlling the Display Of Web Content.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Cascading Style Sheets Controlling the Display Of Web Content.
Tutorial 4 Creating Special Effects with CSS
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
CSS: Cascading Style Sheets. 2 History HTML tags were originally designed to define the content of a document. The layout of the document was supposed.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
Chapter 7 Web Typography Principles of Web Design, 4 th Edition.
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.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
New Perspectives on XML, 2nd Edition Tutorial 5 1 TUTORIAL 5 WORKING WITH CASCADING STYLE SHEETS.
XP New Perspectives on XML Tutorial 5 1 TUTORIAL 5 CSS Tutorial – Carey ISBN
การจัดรูปแบบเว็บด้วย CSS การเขียนโปรแกรมเว็บ. Selectors & cascading PatternMeaning *Universal selector: matches any element. EType selector: matches any.
Tutorial 4 Creating Special Effects with CSS
1 Cascading Style Sheets (CSS) Part 2. 2 The Sources of Style Sheets.
1 Working with Cascading Style Sheet (CSS) (contd.)  What we will cover… 1. Color (decimal and hexadecimal representation) 2. Floating elements 3. Styling.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 7.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 7.
MySQL and PHP Review CSS. Cascading Style Sheet (CSS) Style sheets are files or forms that describe the layout and appearance of a document. Cascading.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
Cascading Style Sheets Eugenia Fernandez IUPUI. CSS Purpose CSS allow you to specify the style in which your XML elements are displayed. CSS were originally.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
THE BOX MODEL Putting layouts together with CSS. The Box Model  How would you describe a box?  Container?  Tags or elements are “containers”  puts.
Cascading Style Sheets Positioning Controls Visibility.
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
Positioning and Printing Creating Special Effects with CSS.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
3.2 Cascading Style Sheets. 2 Positioning Elements Normally, elements are laid out on the page in the order that they are defined in the XHTML document.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
Maureen Smith Professor Tutorial 4.  Review  Session 4.1  Session 4.2  Session 4.3  Review.
Tutorial 4 Creating Page Layouts with CSS
Cascading Style Sheets CSS2 - a bit more advanced.
CSS: Cascading Style Sheets Part II. Style Syntax.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 6.
Understanding CSS Cascading Style Sheets control the presentation of content in HTML pages Style Sheets separate formatting from the content –Styles defined.
Chapter 7.  Change body and link styles  Create a drop-down menu  Change color and font styles in the menu  Create a pop-up effect using CSS  Utilize.
HTML 5 AND CSS Dr Mohd Soperi Mohd Zahid Semester /16.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 8.
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
CSS.
Laying out Elements with CSS
Working with Cascading Style Sheets
Web Systems & Technologies
Objectives Create a media query Work with the browser viewport
Objectives Create a reset style sheet Explore page layout designs
6 Layout.
For the World Wide Web Positioning Objects with CSS
Web Development & Design Foundations with H T M L 5
Tutorial 4 Creating Special Effects with CSS
The Internet 10/20/11 CSS Layout
Cascading Style Sheets
Cascading Style Sheets™ (CSS)
Presentation transcript:

CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1

Objectives First, the labs… Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover effect Create a drop cap using a pseudo-element Manage page layout with CSS Work with overflow and clipping styles Apply styles to various media Hide elements from printing Apply printer styles and page breaks for printing CS202 2

Review of CSS (Chapter 4) Background ◦ background-attachment: fixed; background-attachment: fixed; ◦ background-attachment: scrolled; background-attachment: scrolled; Text Decoration: ◦ links links ◦ fonts fonts Boxes: ◦ General info General info ◦ Mix and match classes Mix and match classes ◦ Border Style Border Style Visibility: ◦ Changing from: visibility: hidden Changing from: visibility: hidden All of that leading to DHTMLDHTML CS202 3

Working with Selector Patterns On a Web page, elements are nested within other elements, forming a hierarchical tree structure CS202 4

Working with Selector Patterns The tree structure allows CSS to create contextual selectors ◦ Express location of an element within the hierarchy of elements parent descendant {styles} li b {color: blue} li b, h2 {color: blue} #notes b {color: blue} * {color: blue} p > b {color: blue} CS202 5

Using Selector Patterns To apply a style to  a single element  use the e selector /* e is the name of the element */  all elements  use the * selector  a descendant element (f)  use the e f selector /* e is the parent and f is an element nested within the parent */  a child element (f)  use the e > f selector /* (e) is the name of a parent and (f) is a direct child  a sibling element  use the e + f selector /* (e) and (f) are siblings and (f) immediately follows (e) in the document tree */ CS202 6

Working with Selector Patterns Can also select elements based on their attribute element[att] {styles} a[href] {color: blue} See ◦  title is one of “core attributes” (class, id,style and title)core attributes And ◦ ◦ CS202 7

Working with Selector Patterns Conditional comments allow you to apply different HTML code for different versions of Internet Explorer HTML code And browsers extensions (page 237) extensions CS202 8

Using Pseudo-Classes and Pseudo-Elements Pseudo-elements are abstracted from what we know of an element’s content, use, or position in the document Pseudo-elements selector:pseudo-element {styles} CS202 9

Using Pseudo-Classes and Pseudo- Elements A pseudo-class is a classification of an element based on its status, position, or current use in the documentpseudo-class Rollover effects can be created using pseudo-classes ◦ About CSS 10

Positioning Objects with CSS CS202 11

Positioning Objects with CSS Create div containers for each note Add a class attribute to apply a common set of styles Each note should have a unique id or class (example)example CS202 12

Positioning Objects with CSS CSS-P (CSS-Positioning) ◦ part of the specification for CSS2 ◦ positioning styles adopted by browsers type; top: value; right: value; bottom: value; left: value; Absolute positioning ◦ enables you to place an element at specific coordinates either on a page or within a containing element position: absolute; left: 100px; top: 50px Relative positioning ◦ used to move an element relative to its default position on the page position: relative; left: 100px; top: 50px  You can fix an element at a specific spot in the document window while the rest of the page scrolls by setting the value of the position style to fixedfix an element  You can assign the inherit position style to an element so that it inherits the position value of its parent element CS202 13

Positioning Objects with CSS About CSS 14 The different positioning styles aka (CSS1 specs) CSS-Positioning or CSS-P To place an element at a specific position on a page use: position: type; top: value; right: value; bottom: value; left: value;

Positioning Objects with CSS CS202 15

Stacking Elements About CSS 16 Specify stacking order with: z-index: value z-index: 3 z-index: 1 z-index: 2

Stacking Elements Elements placed using CSS positioning are stacked on top of elements that are not To specify a different stacking order, use the style: z-index: value CS202 17

Working with Overflow and Clipping The overflow property syntax: ◦ overflow: type overflow: type If you want to force an element into a specified height and width, you have to define how the browser should handle a situation where content overflows the space allotted to the object overflow: type CS202 18

Working with Overflow and Clipping and Clippingand Clipping The clip style allows you to define a rectangular region through which the element’s content can be viewed clip: rect(top, right, bottom, left) CS202 19

Hiding Elements CSS has two styles that you can use to keep an element from being displayed in the output: ◦ the display style ◦ the visibility style visibility: type The type attribute can be set to visible, hidden, collapse, or inherit CS202 20

Comparing the visibility and display styles About CSS 21 Visibility hidden Object is hidden but still is part of the page flow Display: none Object is hidden and is removed from the page flow

Working with Different Media About CSS 22 By default, a style sheet is applied to all devices each device must determine how best to match the styles to its own requirements You can specify output styles for particular devices in the media attribute of the link and style elements... or

Rule About CSS 23 You can also specify the output media within a style sheet type {style declarations} Where media is one of the supported media types and style declarations are the styles associated with that media type

Media Groups About CSS 24 CSS2 uses media groups to describe basic facets of different media and to differentiate between different types of media based on the ways they render content –Continuous or paged –Visual, aural, or tactile –Grid or bitmap –Interactive or static –Various media typesVarious media types

Working with Different Media You can use a single style sheet broken down into different sections for each media screen { body {font-size: 1em} h1 {font-size: 2em} print { body {font-size: 12pt} h1 {font-size: 16pt} handheld { body {font-size: 8pt} h1 {font-size: 12pt} tv { body {font-size: 16pt} h1 {font-size: 24pt} } CS202 25

Working with Different Media CSS uses media groups to describe how different media devices render content ◦ Continuous or paged ◦ Visual, aural, or tactile ◦ Grid (for character grid devices) or bitmap ◦ Interactive (for devices that allow user interaction) or static (for devices that allow no interaction) CS202 26

Using Print Styles CSS defines printed pages by extending the box model You can specify the size of a page, margins, internal padding, etc. of the page box (Check page HTML 248 for working with print styles) CS202 27

Using Print Styles The general rule to create and define a page box {styles} Printed media can vary in size and orientation The size style allows the Web author to define the default dimensions and orientation of the printed page size: width height orientation CS202 28

Working with Page Breaks Page BreaksPage Breaks The printer will decide the location of the page breaks page-break-before: type page-break-after: type hr {page-break-after: always} CS202 29

Working with Page Breaks Working with Page Breaks The type style attribute has the following values: ◦ Always, Avoid, Left, Right, Auto and Inherit Widow: ◦ only a few lines of an element at the top of a page Orphan: ◦ only a few beginning lines of an element appear at the bottom of a page The styles to control the appearance of widows and orphans in the printout are: widow: value orphan: value CS202 30