CSS WORKSHOP Design Principles for Web Standards.

Slides:



Advertisements
Similar presentations
Cascading Style Sheets
Advertisements

Cascading Style Sheets
CSS CSS Precise Aesthetic Control. Cascading Style Sheets Though they can be put in HTML header, usually a separate page that the HTML links to Contains.
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.
Tutorial 4: Creating page layout with css
1 Dynamic HTML: Cascading Style Sheets™ (CSS). 2 Introduction Cascading Style Sheets (CSS) –Specify the style of your page elements –Spacing, margins,
CS4370/6370 Web Development Cascading Style Sheets (CSS)
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
Web Design & Development Cascading Style Sheets (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.
IMAGES Controlling size of images in CSS Aligning images in CSS Adding background images.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Cascading Style Sheets Billy Toy Cascading Style Sheets Syntax review How to Implement style sheets Background properties Text properties.
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.
CSS Dvijesh Bhatt.
LING 408/508: Programming for Linguists
Cascading style sheets (CSS)
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
Chapter 7 Web Typography Principles of Web Design, 4 th Edition.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
CS105 INTRODUCTION TO COMPUTER CONCEPTS CASCADING STYLE SHEETS (CSS) Instructor: Cuong (Charlie) Pham.
New Perspectives on XML, 2nd Edition Tutorial 5 1 TUTORIAL 5 WORKING WITH CASCADING STYLE SHEETS.
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
1 Cascading Style Sheets (CSS) Part 2. 2 The Sources of Style Sheets.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
CSS. HTML: Looking Back HTML dictates order, structure, and function Does very little to specify layout or visual rendering.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
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.
Ch 10 HTML and CSS Web Standards Solutions A Web Standardistas’ Approach.
Lesson 03 // Cascading Style Sheets. CSS Stands for Cascading Style Sheets. We’ll be using a combination of Html and CSS to create websites. CSS is a.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes.
COMP 135 Web Site Design Intermediate
>> The “Box” Model. Pre-requisite Create a new project in Netbeans called Week5 Create a new html file and name it box.html Create a new css file and.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
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.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
CIS234A Lecture 5 Instructor Greg D’Andrea. Font Styles Review Font-Family: generic family, font family Font-Size: em, pt, px, %, mm, cm, in Font-Style:
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.
Cascading Style Sheets Primary readings Presentations Explain & review projects with class mates.
 HTML, CSS, JavaScript – enormously successful  SASS has all the tools we need! INTRO.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
Developing Web Applications with HTML and CSS “Selectors and Properties”
CSS: Cascading Style Sheets Part II. Style Syntax.
Review First – on your own... Go to Day 5 Grab the contents of position review file Place in DW Add styles to recreate – get something close to
Cascading Style Sheet (CSS) SAMPLE IT133 Pengembangan Web.
04 – CSS Informatics Department Parahyangan Catholic University.
PERSPECTIVES: TUTORIAL 4 CREATING PAGE LAYOUTS WITH CSS.
How CSS works Dr. Reda Salama 1. What is CSS Cascading Style Sheets Contains the rules for the presentation of HTML. + = HTMLCSSWeb Page CSS was introduced.
CS 120: Introduction to Web Programming Lecture 10: Extra Features and Website Design Part 1 Tarik Booker CS 120 California State University, Los Angeles.
HTML 5 AND CSS Dr Mohd Soperi Mohd Zahid Semester /16.
1 CS428 Web Engineering Lecture 07 Font, Text & Background (CSS - II)
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
HTML & CSS Contents: the different ways we can use to apply CSS to The HTML documents CSS Colors and Background CSS Fonts CSS Text CSS box model: padding,
>> CSS Layouts. Recall Properties of Box – Border (style, width, color) – Padding – Margin – Display – Background – Dimension Welcome Padding Area Border.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
CSS.
Laying out Elements with CSS
Cascading Style Sheets (Layout)
CSS Borders and Margins.
Presentation transcript:

CSS WORKSHOP Design Principles for Web Standards

“Every line of CSS you write is a suggestion. You are not dictating how the HTML should be rendered; you are suggesting how the HTML should be rendered.” Jeremy Keith

CSS RULES p.introduction { line-height: 1.5; text-align: center; margin-bottom: 1rem; } selector property value declaration

CASCADING PRINCIPLES B rowser's default User's styles Author's styles

INHERITANCE The headline is important!

SELECTORS Selectors allow us to target a specific HTML element to apply rules to it in a CSS declaration.

SELECTORS -Type Selectors -ID Selectors -Class Selectors -Contextual Selectors -Attribute Selectors -Pseudo-classes Selectors -Pseudo-elements Selectors -Adjacent Selectors

p { font-size: 0.9em } TYPE SELECTORS

#main { border: 1px solid; } ID SELECTORS

.alert { color: #C00; } CLASS SELECTORS

p span{ font-size: 90%; } CONTEXTUAL SELECTORS

input[type=submit] { color: #FFF; background: #C00; } ATTRIBUTE SELECTORS

a:hover { text-decoration: none; } PSEUDO-CLASSES SELECTORS

li:last-child { border: none; } STRUCTURAL PSEUDO-CLASSES

p::before { content: ‘>’; } PSEUDO-ELEMENTS SELECTORS

/* Descendents */ #main h2 {…} #main > h2 {…} /* Siblings */ h2 ~ h3 {…} h2 + h3 {…} CHILD & ADJACENT SELECTORS

SELECTOR SPECIFICITY

- Equal specificity: the latest rule is the one that counts. - Unequal specificity: the more specific rule is the one that counts.

PROPERTIES AND VALUES -Font &Text Styles -Color & Shape -Display & Dimensions -Positioning and Layout

SELECTORS Hands-on

FONT & TEXT STYLES My text p.mytext { font-family: Arial, sans-serif; font-size: 2em; font-weight: bold; }

FONT & TEXT STYLES M Y T E X T p.mytext { … text-align: center; letter-spacing: 0.3em; text-transform: uppercase; }

COLOR & SHAPE M Y T E X T p.mytext { … color: #00CC33; background: #FFFFF; border-weight: 5px; border-type: solid; border-color: #FF0000; }

COLOR & SHAPE M Y T E X T p.mytext { … color: #0C3; background: #FFF; border: 5px solid #F00; }

COLOR & SHAPE M Y T E X T p.mytext { … background-image: url(myimage.jpg); background-position: 0 0; background-repeat: no-repeat; }

BASICS Hands-on

DISPLAY & DIMENSIONS When your browser displays an element, the element takes up space. You can think of all HTML elements as boxes. All boxes have certain dimensions and are specified by four properties: a content area of the element (e.g., a picture, a text header, etc.) and the optional padding, border and margin properties.padding bordermargin

DISPLAY & DIMENSIONS: The Box Model

div.mybox { width: 500px; height: 200px; padding: 20px; margin: 10px 5px 10px 5px; border: 5px solid #FFF; }

DISPLAY DIMENSIONS: The Box Model div.mybox { box-sizing: border-box; // or padding-box width: 500px; height: 200px; padding: 20px; margin: 10px 5px 10px 5px; border: 5px solid #FFF; }

DISPLAY & DIMENSIONS Block Elements -A block-level element occupies the entire space of its parent element. -Browsers typically display the block- level element with a new line both before and after the element. div, section, article, aside, footer, header, h1, h2…, p, etc.

DISPLAY & DIMENSIONS Inline Elements -An inline-level element has no dimensions (no width/height) -Browsers typically display the inline- level elements one beside the other. a, span, strong, em, input, etc.

DISPLAY & DIMENSIONS a { display: inline-block; } Home Home Next Next

DISPLAY & DIMENSIONS a { display: block; } Home Next

POSITIONING AND LAYOUT -Position -Float -Flex -Grid, …

POSITION PROPERTY Absolute. child{ position: absolute; width: 55%; top: 0; left:0; }

POSITION PROPERTY Absolute.father { margin: 20px; }.child{ position: absolute; width: 55%; top: 0; left:0; }

POSITION PROPERTY Absolute.father { position: relative; margin: 20px; }.child{ position: absolute; width: 55%; top: 0; left:0; }

POSITION PROPERTY Relative.father { position: relative; margin: 20px; top: 20px left: 20px; }.child{ position: absolute; width: 55%; bottom: 5px; right: 5px; }

FLOAT POSITIONING

FLOAT POSITIONING div { float: left; width: 30%; margin: 1% 1% 0; }

FLOAT POSITIONING div { float: right; width: 30%; margin: 1% 1% 0; }

FLOAT POSITIONING father { background-color: #CCC; }.father div { float: left; width: 30%; margin: 1% 1% 0; }

FLOAT POSITIONING father { float: left; width: 100%; background-color: #CCC; }.father div { float: left; width: 30%; margin: 1% 1% 0; }

POSITIONING Hands-on

FLEX POSITIONING The flex CSS property is a shorthand property specifying the ability of a flex item to alter its dimensions to fill available space. Flex items can be stretched to use available space proportional to their flex grow factor or their flex shrink factor to prevent overflow.CSSshorthand

FLEX POSITIONING

div.father { display: flex; display: -webkit-flex; } First, tell the container its kids are « flex »:

FLEX POSITIONING div.father div { flex: 1 0 auto; -webkit-flex: 1 0 auto; } Then, determine how the kids will behave:

FLEX POSITIONING div.father { display: flex; display: -webkit-flex; flex-direction: row; -webkit-flex-direction: row; } Flow of content: flow-direction

FLEX POSITIONING div.father { display: flex; display: -webkit-flex; flex-wrap: wrap; -webkit-flex-wrap: wrap; } Flow of content: flow-wrap

FLEX POSITIONING div.father { display: flex; display: -webkit-flex; flex-flow: row wrap; -webkit-flex-flow: row wrap; } Flow of content: A Shorthand flexcontainer { flex-flow: || ; }

FLEX POSITIONING div.father { display: flex; display: -webkit-flex; flex-flow: row wrap; -webkit-flex-flow: row wrap; justify-content: center; -webkit-justify-content: center; } Alignment of content (main-axis): justify-content

FLEX POSITIONING div.father { display: flex; display: -webkit-flex; flex-flow: row wrap; -webkit-flex-flow: row wrap; align-content: center; -webkit-align-content: center; } Alignment of content (cross-axis): align-content My kids are displayed in multiple lines!

FLEX POSITIONING div.father { display: flex; display: -webkit-flex; flex-flow: row wrap; -webkit-flex-flow: row wrap; align-items: center; -webkit-align-items: center; } Alignment of content (perpendicular): align-items

FLEX POSITIONING div.father { display: flex; display: -webkit-flex; flex-flow: row wrap; -webkit-flex-flow: row wrap; } div.father div { flex-basis: 35%; -webkit-flex-basis: 35%; } Flex item behavior: flex-basis

FLEX POSITIONING div.father { display: flex; display: -webkit-flex; } div.father div { flex-basis: 5%; } div.father div:nth-child(3) { flex-grow: 3; } Flex item behavior: flex-grow

FLEX POSITIONING div.father { display: flex; display: -webkit-flex; } div.father div { flex-basis: 5%; } div.father div:nth-child(3) { flex-shrink: 0; } Flex item behavior: flex-shrink

FLEX POSITIONING div.father { display: flex; display: -webkit-flex; flex-flow: row wrap; -webkit-flex-flow: row wrap; } div.father div { flex: 1 1 auto; } Flex item behavior: A Shorthand flexitem { flex: || || ; }

FLEX POSITIONING div.father { display: flex; display: -webkit-flex; flex-flow: row wrap; -webkit-flex-flow: row wrap; } div.father div:nth-child(3) { flex: 1 1 auto; order: -1; } Flex item order: order 3124

FLEX POSITIONING Hands-on

MEDIA QUERIES -Syntax -Types -Features -Tools

MEDIA QUERIES CSS at-rule associates a set of nested statements, in a CSS block that is delimited by curly braces, with a condition defined by a media query. at- rule may be used not only at the top level of a CSS, but also inside any CSS conditional- group at-rule.CSSat-rulemedia queryCSS conditional- group at-rule

MEDIA QUERIES Syntax #wrapper { … { /* media-specific rules */ #wrapper { … } }

MEDIA QUERIES Types -All -Print -Screen -Speech

MEDIA QUERIES Features -min-width -max-width -orientation, resolution, …

MEDIA QUERIES Syntax #wrapper { … screen and (min-width: 500px ){ /* media-specific rules */ #wrapper { … } }

MEDIA QUERIES Syntax #wrapper { … screen and (min-width: 500px) and (max-width: 800px) { /* media-specific rules */ #wrapper { … } }

MEDIA QUERIES Tools -Ripple -Google Chrome Console -Firefox (Ctrl+Maj+M)

REFERENCES -Kawwa -Web Platform -Mozilla Developer Network -Flex Box Cheatsheets