SlideShare ist ein Scribd-Unternehmen logo
1 von 54
CSS Essentials
For the one who care about layout




                 Tin@BrowBag 3 June 2011
Agenda
XHTML & CSS
CSS selector
Visual formatting & models
Basic sample
Advanced sample
Tricks and hacks
CSS define the visual model
Layout
Typography
Units
Rendering
Graphics
etc.
Era of CSS
Before the   movable-   Moden publishing
dawn         type
                        CSS 3
Agenda
XHTML & CSS
CSS selector
Visual formatting & models
Basic sample
Advanced sample
Tricks and hacks
XHTML and CSS
XHTML => data (structure)
CSS => presentation (visual)
Separation of concerns
Best practices:
  Use proper HTML tags
  Use meaningful class/id name (red-text warn-text)
  Minimizing HTML structure and CSS rules
Example of html
Agenda
XHTML & CSS
CSS selector
Visual formatting & models
Basic sample
Advanced sample
Tricks and hacks
CSS selector - Rule Structure
Selector             Declaration block

            Declaration        Declaration

  H1       { color: red;    background: yellow;   }


           Property Value    Property    Value
CSS selector - Basic
Element Selector
  Type selector: h1 { font-weight: bold;}
  Descendant selector: li a { text-decoration: none; }
Class Selector
  .warn { color: red }
  .full-width { width: 100% }
CSS selector - Basic
ID Selector
  #sidebar { float: right; width: 27em; }
Pseudo class
  a:link { color: blue; }
  li:hover { background-color: grey; }
  input:focus { background-color: yellow; }
  All pseudo class:
    :active, :after, :before, :first-child, :first-letter, :first-
    line, :focus, :hover, :lang, :link, :visited
CSS selector - advanced
Universal (wildcard) Selector
  * { padding: 0; margin: 0; }
Child selector: #nav > li
Adjacent Sibling selector: h1 + p
Simple Attribute selector:
  div[class]
  input[type=”input”], div[id~=”container”] ...
CSS Rule Specificity (Weight)
 Four level of specificity
   level 1(1000): inline style, <div style=”color: red”>
   level 2(0100): ID selector
   level 3(0010): class, pseudo class, attribute selector
   level 4(0001): element selector, universal selector
   Special level: !important (except IE6)
   Draw game: last declaration win
CSS Rule Specificity
Rule                    Weight      Weight (digit)
Style=””               1, 0, 0, 0      1000
#wrapped #content {}   0, 2, 0, 0       200
#content .date {}      0, 1, 1, 0       110
div#content {}         0, 1, 0, 1       101
#content {}            0, 1, 0, 0       100
p.comment .date {}     0, 0, 2, 1        21
p.comment {}           0,0, 1, 1         11
div p {}               0, 0, 0, 2         2
p {}                   0, 0, 0, 1         1
CSS: Inherit and cascading

Inheritance: Inherit ancestor element’s style, color,
font-size (font*)
  descendants in dom tree inherit ancestor’s style
  none inherit: padding, margin, border, background
  no specificity (lowest priority)
CSS: Inherit and cascading
Cascading: different level of css rule composite
together
  all match selector declarations will be applied
    browser default style
    Inheritance
    selector declarations from lower to higher specificity
    the styles with !important
    later property overwrite former property
How to use them?
Real example (by Firebug)
Agenda
XHTML & CSS
CSS selector
Visual formatting & models
Basic sample
Advanced sample
Tricks and hacks
Element Classification
Nonreplaced Elements
  The majority of HTML elements are NE
  Their content box is generate by itself
Replaced Elements
  content box is replaced by something not directly
  represented by document content
  Image, flash object, input element
Everything start form the ‘display’ model



“The display property
specifies the type of box
an element should
generate.”
Era of CSS
Before the   movable-   Moden publishing
dawn         type
                        CSS 3
What’s the box?
Basic Box model
     margin: top right bottom left;
                border
               padding
        width

            Content Area
                        height
Basic Box model                  Background
     margin: top right bottom left;
                border
               padding
        width

            Content Area
                        height
Box model example (in firebug)
IE box model quirks
                                                                             W3C
                                                                                    Actual width = margin * 2 + padding*2 +
                                                                                    border * 2 + width (css property)

                                                                                    content-width = width (css property)

                                                                             IE
                                                                                    Actual width = margin * 2 + width (css
                                                                                    property)

                                                                                    content-width = width - padding * 2


This file is licensed under the Creative Commons Attribution ShareAlike 3.0 Unported (http://en.wikipedia.org/wiki/Image:W3C_and_Internet_Explorer_box_models.png)
So... for IE compatibility

 Normally, don’t use padding and margin on same
 element, use it in different level
 Make IE doesn't work in quirks-mode
 Has-layout=true (zoom: 1, but can’t pass w3c validation)
 Don’t use width: 100% and padding on same element (for
 safty, use 95% or other safe value)
Element Display Roles - Block Level
 Block-Level is a element with property display: block
 It generate a box fills its parent’s content area
 can’t have other element on it’s side
 it generate breaks before/after it’s box
 Use width/height to determine the size
 min-width/max-width
 Div is block element by default
 Use overflow control overflow content display/hide
Block-Level Layout

It generate a rectangular box called element box, which
describes the amount of space occupied by an element
  Background extends to the outer edge of the border
  Only margins, height, and width may be set to auto
  Only margins can be given negative values
  Padding & borders of element box default to 0 & none
  Width property define only the width of content area
Block box formating

        margin: top right bottom left;
                   border
                  padding
           width

               Content Area
                           height
Block box formating
        The containing block
                                                                      border
                                                                      padding
                  auto margin                             width
                                                                  Content Area
                                                                                 height




negative margin
                                                                     border
                                                                      padding
                                         width
                                                                  Content Area
                                                                                          height




                                   border
                                   padding
   fixed margin          width
                                Content Area
                                                 height
                                                                                          Fixed width
Element Display Roles - Inline Level
 Inline-level is a element with property display: inline
 It generate element box within a line of text and do not
 break up the flow of that line, continues layout
 The box size is determined by it’s content
 inline element can only contain inline element
 Margin has no effect here
 line-height and vertical-align
 inline-height, inline-width (not recommended)
 font-size
Inline-Level Layout

content
 area           inline element              inline box


              content area   half-leading


  which is   Strongly emphasized      and which is
Inline-Level Layout

content
 area           inline element              inline box


              content area   half-leading


  which is   Strongly emphasized       and which is


                                 baseline
Inline box formating

  The containing block
    which is   Strongly emphasized   which is

    beijing oepn party   is good
Normal layout flow
Other Element Display Roles

Inline-block: it has no breaks, but you can specific
width and height on it
display: none (totally hide the content, remove it from
layout flow)
  about visibility: hide (do not display the content, but
  still take effect in layout flow)
Steal from http://www.slideshare.net/stopsatgreen/the-home-of-tomorrow-css-layouts

Future Layout Modules
Steal from http://www.slideshare.net/stopsatgreen/the-home-of-tomorrow-css-layouts

Future Layout Modules
Steal from http://www.slideshare.net/stopsatgreen/the-home-of-tomorrow-css-layouts

Future Layout Modules
Steal from http://www.slideshare.net/stopsatgreen/the-home-of-tomorrow-css-layouts

Future Layout Modules
Steal from http://www.slideshare.net/stopsatgreen/the-home-of-tomorrow-css-layouts

Future Layout Modules
Control the layout
 Floating Layout            Absolute positioning
   Left, right float         Fixed positioning
   Clear float               z-index
   Shrink to fit           Table Layout
 Positioning Layout         Fixed table layout
   Static positioning       Automatic table layout
   Relative positioning
Values and Units
Color Values                  Length Values
  #RRGGBB                       Absolute length units
  #RGB                            Inches (in)
  rgb(rrr.rr%, ggg.gg%,           Centimeters (cm)
  bbb.bb%)
                                  Millimeters (mm)
  rgb(rrr, ggg, bbb)
                                  Points (pt) 12pt = 1in
  keyword (black, blue ...)
                                  Picas (pc)
Values and Units
Length Values
  Relative length units
    em-height (em)
    x-height (ex)
    Pixels (px)
Percentage Values (%)
Agenda
XHTML & CSS
CSS selector
Visual formatting & models
Basic sample
Advanced sample
Tricks and hacks
CSS basic example
Style for font (size, weight, color, style, family)
Style for link
  love/hate
  rollover (spry)
Style for float image and clear
Style for background
Agenda
XHTML & CSS
CSS selector
Visual formatting & models
Basic sample
Advanced sample
Tricks and hacks
CSS Advanced example
Image button      rounded corner
horizontal menu     fixed width
css tooltip         mountain corner
slide door tab      4 wrapped bg images
                    4 corner images
                    css rounded corner
Agenda
XHTML & CSS
CSS selector
Visual formatting & models
Basic sample
Advanced sample
Tricks and hacks
Hacks and Tricks
Most hacks is for IE          Tricks for IE
  Star hack (6)                 min-width/width(6)
  Underscore hack (7)           <!--[if lte IE 7]>
  !important (6)                 <![endif]-->
  > child selector (-5, -6)
  property selector
  has-layout? zoom: 1
You are coming a long way,
baby
Thanks!

Weitere ähnliche Inhalte

Ähnlich wie CSS Essentials: Layout Fundamentals and Visual Formatting Models

Ähnlich wie CSS Essentials: Layout Fundamentals and Visual Formatting Models (20)

Web Layout
Web LayoutWeb Layout
Web Layout
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
 
5. Web Technology CSS Advanced
5. Web Technology CSS Advanced 5. Web Technology CSS Advanced
5. Web Technology CSS Advanced
 
Dimensions of elements.pdf
Dimensions of elements.pdfDimensions of elements.pdf
Dimensions of elements.pdf
 
Static layouts with css
Static layouts with cssStatic layouts with css
Static layouts with css
 
CSS
CSSCSS
CSS
 
CSS.pptx
CSS.pptxCSS.pptx
CSS.pptx
 
CSS and CSS3
CSS and CSS3CSS and CSS3
CSS and CSS3
 
Box Model
Box ModelBox Model
Box Model
 
Css box model
Css box modelCss box model
Css box model
 
CSS Foundations, pt 2
CSS Foundations, pt 2CSS Foundations, pt 2
CSS Foundations, pt 2
 
Web Development - Lecture 6
Web Development - Lecture 6Web Development - Lecture 6
Web Development - Lecture 6
 
Html5
Html5Html5
Html5
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 
Lecture-8.pptx
Lecture-8.pptxLecture-8.pptx
Lecture-8.pptx
 
Concept of CSS part 2
Concept of CSS part 2Concept of CSS part 2
Concept of CSS part 2
 
Accessibility and css - Lisa Seeman
Accessibility and css - Lisa SeemanAccessibility and css - Lisa Seeman
Accessibility and css - Lisa Seeman
 
Css training
Css trainingCss training
Css training
 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01
 
Ppt ch06
Ppt ch06Ppt ch06
Ppt ch06
 

Kürzlich hochgeladen

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Kürzlich hochgeladen (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

CSS Essentials: Layout Fundamentals and Visual Formatting Models

  • 1. CSS Essentials For the one who care about layout Tin@BrowBag 3 June 2011
  • 2. Agenda XHTML & CSS CSS selector Visual formatting & models Basic sample Advanced sample Tricks and hacks
  • 3. CSS define the visual model Layout Typography Units Rendering Graphics etc.
  • 4. Era of CSS Before the movable- Moden publishing dawn type CSS 3
  • 5. Agenda XHTML & CSS CSS selector Visual formatting & models Basic sample Advanced sample Tricks and hacks
  • 6. XHTML and CSS XHTML => data (structure) CSS => presentation (visual) Separation of concerns Best practices: Use proper HTML tags Use meaningful class/id name (red-text warn-text) Minimizing HTML structure and CSS rules
  • 8. Agenda XHTML & CSS CSS selector Visual formatting & models Basic sample Advanced sample Tricks and hacks
  • 9. CSS selector - Rule Structure Selector Declaration block Declaration Declaration H1 { color: red; background: yellow; } Property Value Property Value
  • 10. CSS selector - Basic Element Selector Type selector: h1 { font-weight: bold;} Descendant selector: li a { text-decoration: none; } Class Selector .warn { color: red } .full-width { width: 100% }
  • 11. CSS selector - Basic ID Selector #sidebar { float: right; width: 27em; } Pseudo class a:link { color: blue; } li:hover { background-color: grey; } input:focus { background-color: yellow; } All pseudo class: :active, :after, :before, :first-child, :first-letter, :first- line, :focus, :hover, :lang, :link, :visited
  • 12. CSS selector - advanced Universal (wildcard) Selector * { padding: 0; margin: 0; } Child selector: #nav > li Adjacent Sibling selector: h1 + p Simple Attribute selector: div[class] input[type=”input”], div[id~=”container”] ...
  • 13. CSS Rule Specificity (Weight) Four level of specificity level 1(1000): inline style, <div style=”color: red”> level 2(0100): ID selector level 3(0010): class, pseudo class, attribute selector level 4(0001): element selector, universal selector Special level: !important (except IE6) Draw game: last declaration win
  • 14. CSS Rule Specificity Rule Weight Weight (digit) Style=”” 1, 0, 0, 0 1000 #wrapped #content {} 0, 2, 0, 0 200 #content .date {} 0, 1, 1, 0 110 div#content {} 0, 1, 0, 1 101 #content {} 0, 1, 0, 0 100 p.comment .date {} 0, 0, 2, 1 21 p.comment {} 0,0, 1, 1 11 div p {} 0, 0, 0, 2 2 p {} 0, 0, 0, 1 1
  • 15. CSS: Inherit and cascading Inheritance: Inherit ancestor element’s style, color, font-size (font*) descendants in dom tree inherit ancestor’s style none inherit: padding, margin, border, background no specificity (lowest priority)
  • 16. CSS: Inherit and cascading Cascading: different level of css rule composite together all match selector declarations will be applied browser default style Inheritance selector declarations from lower to higher specificity the styles with !important later property overwrite former property
  • 17. How to use them?
  • 18. Real example (by Firebug)
  • 19. Agenda XHTML & CSS CSS selector Visual formatting & models Basic sample Advanced sample Tricks and hacks
  • 20. Element Classification Nonreplaced Elements The majority of HTML elements are NE Their content box is generate by itself Replaced Elements content box is replaced by something not directly represented by document content Image, flash object, input element
  • 21. Everything start form the ‘display’ model “The display property specifies the type of box an element should generate.”
  • 22. Era of CSS Before the movable- Moden publishing dawn type CSS 3
  • 24. Basic Box model margin: top right bottom left; border padding width Content Area height
  • 25. Basic Box model Background margin: top right bottom left; border padding width Content Area height
  • 26. Box model example (in firebug)
  • 27. IE box model quirks W3C Actual width = margin * 2 + padding*2 + border * 2 + width (css property) content-width = width (css property) IE Actual width = margin * 2 + width (css property) content-width = width - padding * 2 This file is licensed under the Creative Commons Attribution ShareAlike 3.0 Unported (http://en.wikipedia.org/wiki/Image:W3C_and_Internet_Explorer_box_models.png)
  • 28. So... for IE compatibility Normally, don’t use padding and margin on same element, use it in different level Make IE doesn't work in quirks-mode Has-layout=true (zoom: 1, but can’t pass w3c validation) Don’t use width: 100% and padding on same element (for safty, use 95% or other safe value)
  • 29. Element Display Roles - Block Level Block-Level is a element with property display: block It generate a box fills its parent’s content area can’t have other element on it’s side it generate breaks before/after it’s box Use width/height to determine the size min-width/max-width Div is block element by default Use overflow control overflow content display/hide
  • 30. Block-Level Layout It generate a rectangular box called element box, which describes the amount of space occupied by an element Background extends to the outer edge of the border Only margins, height, and width may be set to auto Only margins can be given negative values Padding & borders of element box default to 0 & none Width property define only the width of content area
  • 31. Block box formating margin: top right bottom left; border padding width Content Area height
  • 32. Block box formating The containing block border padding auto margin width Content Area height negative margin border padding width Content Area height border padding fixed margin width Content Area height Fixed width
  • 33. Element Display Roles - Inline Level Inline-level is a element with property display: inline It generate element box within a line of text and do not break up the flow of that line, continues layout The box size is determined by it’s content inline element can only contain inline element Margin has no effect here line-height and vertical-align inline-height, inline-width (not recommended) font-size
  • 34. Inline-Level Layout content area inline element inline box content area half-leading which is Strongly emphasized and which is
  • 35. Inline-Level Layout content area inline element inline box content area half-leading which is Strongly emphasized and which is baseline
  • 36. Inline box formating The containing block which is Strongly emphasized which is beijing oepn party is good
  • 38. Other Element Display Roles Inline-block: it has no breaks, but you can specific width and height on it display: none (totally hide the content, remove it from layout flow) about visibility: hide (do not display the content, but still take effect in layout flow)
  • 44. Control the layout Floating Layout Absolute positioning Left, right float Fixed positioning Clear float z-index Shrink to fit Table Layout Positioning Layout Fixed table layout Static positioning Automatic table layout Relative positioning
  • 45. Values and Units Color Values Length Values #RRGGBB Absolute length units #RGB Inches (in) rgb(rrr.rr%, ggg.gg%, Centimeters (cm) bbb.bb%) Millimeters (mm) rgb(rrr, ggg, bbb) Points (pt) 12pt = 1in keyword (black, blue ...) Picas (pc)
  • 46. Values and Units Length Values Relative length units em-height (em) x-height (ex) Pixels (px) Percentage Values (%)
  • 47. Agenda XHTML & CSS CSS selector Visual formatting & models Basic sample Advanced sample Tricks and hacks
  • 48. CSS basic example Style for font (size, weight, color, style, family) Style for link love/hate rollover (spry) Style for float image and clear Style for background
  • 49. Agenda XHTML & CSS CSS selector Visual formatting & models Basic sample Advanced sample Tricks and hacks
  • 50. CSS Advanced example Image button rounded corner horizontal menu fixed width css tooltip mountain corner slide door tab 4 wrapped bg images 4 corner images css rounded corner
  • 51. Agenda XHTML & CSS CSS selector Visual formatting & models Basic sample Advanced sample Tricks and hacks
  • 52. Hacks and Tricks Most hacks is for IE Tricks for IE Star hack (6) min-width/width(6) Underscore hack (7) <!--[if lte IE 7]> !important (6) <![endif]--> > child selector (-5, -6) property selector has-layout? zoom: 1
  • 53. You are coming a long way, baby

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n