SlideShare una empresa de Scribd logo
1 de 31
CSS Layout

Svetlin Nakov
Manager Technical Training
http://nakov.com
Telerik Web Design Course
html5course.telerik.com
Table of Contents
   Positioning
     Positioning inline elements
   Floating
     Left and right
     Clearing
 Opacity
 Visibility

 Display




                                                    2
Positioning



              3
Positioning
 position: defines the positioning of the
    element in the page content flow
   The value is one of:
     static (default)
     relative – relative position according to where
      the element would appear with static position
     absolute – position according to the innermost
      positioned parent element
     fixed – same as absolute, but ignores page
      scrolling
                                                        4
Positioning (2)
 Margin VS relative positioning

 Fixed and absolutely positioned elements do
 not influence the page normal flow and usually
 stay on top of other elements
   Their position and size is ignored when
    calculating the size of parent element or
    position of surrounding elements
   Overlaid according to their z-index
   Inline fixed or absolutely positioned elements
    can apply height like block-level elements
                                                     5
Positioning (3)
 top, left, bottom, right: specifies offset of
 absolute/fixed/relative positioned element as
 numerical values
 z-index : specifies the stack level of
 positioned elements
   Understanding stacking context
  Each positioned element creates a stacking
  context.
  Elements in different stacking contexts are
  overlapped according to the stacking order of
  their containers. For example, there is no way
  for #A1 and #A2 (children of #A) to be placed
  over #B without increasing the z-index of #A.
                                                                     6
Positioning
      Live Demo
positioning-rules.html
Inline element positioning
 vertical-align: sets the vertical-alignment
    of an inline element, according to the line
    height
     Values: baseline, sub, super, top, text-top,
      middle, bottom, text-bottom or numeric
   Also used for content of table cells (which apply
    middle alignment by default)




                                                        8
Alignment and Z-Index
           Live Demo
alignments-and-z-index-rules.html
Floating
Float
 float: the element “floats” to one side

   left: places the element on the left and
    following content on the right
   right: places the element on the right and
    following content on the left
   floated elements should come before the
    content that will wrap around them in the code
   margins of floated elements do not collapse
   floated inline elements can apply height

                                                       11
Float (2)
 How floated elements are positioned




                                                12
Clear
 clear

     Sets the sides of the element where other
      floating elements are NOT allowed
     Used to "drop" elements below floated ones or
      expand a container, which contains only floated
      children
     Possible values: left, right, both
   Clearing floats
     additional element (<div>) with a clear style

                                                        13
Clear (2)
   Clearing floats (continued)
     :after { content: ""; display: block;
      clear: both; height: 0; }
     Triggering hasLayout in IE expands a container
      of floated elements
       display: inline-block;
       zoom: 1;




                                                       14
Floating Elements
     Live Demo
   float-rules.html
Opacity
Opacity
 opacity: specifies the opacity of the element

   Floating point number from 0 to 1
   For old Mozilla browsers use –moz-opacity
   For IE use filter:alpha(opacity=value)
    where value is from 0 to 100; also, "binary and
    script behaviors" must be enabled and
    hasLayout must be triggered, e.g. with zoom:1




                                                      17
Opacity
   Live Demo
opacity-rule.html
Visibility
Visibility
 visibility

  Determines whether the element is visible
  hidden: element is not rendered, but still
   occupies place on the page (similar to
   opacity:0)
  visible: element is rendered normally




                                                    20
Visibility
    Live Demo
visibility-rule.html
Display
Display
 display: controls the displayof the element
 and the way it is rendered and if breaks should
 be placed before and after the element
   inline: no breaks are placed before and after
    (<span> is an inline element)
   block: breaks are placed before AND after the
    element (<div> is a block element)




                                                    23
Display (2)
 display: controls the displayof the element
 and the way it is rendered and if breaks should
 be placed before and after the element
   none: element is hidden and its dimensions are
    not used to calculate the surrounding elements
    rendering (differs from visibility: hidden!)
   There are some more possible values, but not
    all browsers support them
    Specific displays like table-cell and table-row

                                                       24
Display
   Live Demo
display-rule.html
CSS – Part II




Questions?

       http://frontendcourse.telerik.com
Homework
1.   Create the following Web page using HTML and
     external CSS. Using tables, inline styles and
     deprecated tags is not allowed.




                                                     27
Homework (2)
2.   Create the following
     Web page using
     external CSS styles.
     Buttons should consist
     of PNG images with
     text over them.




                                             28
Homework (3)
3.   Create the following Web page using HTML with
     external CSS file. Note that the images should be
     PNG with transparent background.




                                                         29
Homework (4)
4.       Given the picture below create the Web site
          Use CSS and HTML 5




                                                       30
Homework (5)
5.    Create the following HTML 5 Page
      Do it without tables




                                                   31

Más contenido relacionado

Similar a Css layout

Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
WDES106 CSS Advanced Part 1
WDES106 CSS Advanced Part 1WDES106 CSS Advanced Part 1
WDES106 CSS Advanced Part 1
Gene Babon
 
Introduction to CSS: Part Deux
Introduction to CSS: Part DeuxIntroduction to CSS: Part Deux
Introduction to CSS: Part Deux
Larry King
 

Similar a Css layout (20)

Fundamentals of Browser Rendering Css Overview PT 2
Fundamentals of Browser Rendering Css Overview PT 2Fundamentals of Browser Rendering Css Overview PT 2
Fundamentals of Browser Rendering Css Overview PT 2
 
Web Design & Development - Session 3
Web Design & Development - Session 3Web Design & Development - Session 3
Web Design & Development - Session 3
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
 
Displaying.pptx
Displaying.pptxDisplaying.pptx
Displaying.pptx
 
CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)
 
Advanced CSS.pptx
Advanced CSS.pptxAdvanced CSS.pptx
Advanced CSS.pptx
 
CSS3 Refresher
CSS3 RefresherCSS3 Refresher
CSS3 Refresher
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
 
Floats
FloatsFloats
Floats
 
Exp13 write up
Exp13 write upExp13 write up
Exp13 write up
 
Css advanced – session 4
Css advanced – session 4Css advanced – session 4
Css advanced – session 4
 
HTML5 and CSS3
HTML5 and CSS3HTML5 and CSS3
HTML5 and CSS3
 
WDES106 CSS Advanced Part 1
WDES106 CSS Advanced Part 1WDES106 CSS Advanced Part 1
WDES106 CSS Advanced Part 1
 
Fundamentals of Browser Rendering Css Overview PT 1
Fundamentals of Browser Rendering Css Overview PT 1Fundamentals of Browser Rendering Css Overview PT 1
Fundamentals of Browser Rendering Css Overview PT 1
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
Introduction to CSS: Part Deux
Introduction to CSS: Part DeuxIntroduction to CSS: Part Deux
Introduction to CSS: Part Deux
 
Web Programming Basic topic.pptx
Web Programming Basic topic.pptxWeb Programming Basic topic.pptx
Web Programming Basic topic.pptx
 
Leveling Up With Flexbox (Smart Web Conference)
Leveling Up With Flexbox (Smart Web Conference)Leveling Up With Flexbox (Smart Web Conference)
Leveling Up With Flexbox (Smart Web Conference)
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
HTML and CSS part 3
HTML and CSS part 3HTML and CSS part 3
HTML and CSS part 3
 

Más de club23

Más de club23 (15)

Ms office word 2007
Ms office word 2007Ms office word 2007
Ms office word 2007
 
кои сме ние
кои сме ниекои сме ние
кои сме ние
 
Karma
KarmaKarma
Karma
 
компания2
компания2компания2
компания2
 
използване на специализирани програми за получаване и изпращане на файлове в ...
използване на специализирани програми за получаване и изпращане на файлове в ...използване на специализирани програми за получаване и изпращане на файлове в ...
използване на специализирани програми за получаване и изпращане на файлове в ...
 
Html 5-tables-forms-frames (1)
Html 5-tables-forms-frames (1)Html 5-tables-forms-frames (1)
Html 5-tables-forms-frames (1)
 
Project 1 challenge
Project 1   challenge Project 1   challenge
Project 1 challenge
 
Project 1 module 3 -9kl
Project 1   module 3 -9klProject 1   module 3 -9kl
Project 1 module 3 -9kl
 
Project 1 module 2-9kl
Project 1   module 2-9klProject 1   module 2-9kl
Project 1 module 2-9kl
 
Project 1 module 1-9kl
Project 1   module 1-9klProject 1   module 1-9kl
Project 1 module 1-9kl
 
20090510 unicheats.net 520_6094
20090510 unicheats.net 520_609420090510 unicheats.net 520_6094
20090510 unicheats.net 520_6094
 
Kolelo
KoleloKolelo
Kolelo
 
Proekt
ProektProekt
Proekt
 
Prolet
ProletProlet
Prolet
 
езици за програмиране. Php
езици за програмиране. Phpезици за програмиране. Php
езици за програмиране. Php
 

Último

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Último (20)

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Css layout

  • 1. CSS Layout Svetlin Nakov Manager Technical Training http://nakov.com Telerik Web Design Course html5course.telerik.com
  • 2. Table of Contents  Positioning  Positioning inline elements  Floating  Left and right  Clearing  Opacity  Visibility  Display 2
  • 4. Positioning  position: defines the positioning of the element in the page content flow  The value is one of:  static (default)  relative – relative position according to where the element would appear with static position  absolute – position according to the innermost positioned parent element  fixed – same as absolute, but ignores page scrolling 4
  • 5. Positioning (2)  Margin VS relative positioning  Fixed and absolutely positioned elements do not influence the page normal flow and usually stay on top of other elements  Their position and size is ignored when calculating the size of parent element or position of surrounding elements  Overlaid according to their z-index  Inline fixed or absolutely positioned elements can apply height like block-level elements 5
  • 6. Positioning (3)  top, left, bottom, right: specifies offset of absolute/fixed/relative positioned element as numerical values  z-index : specifies the stack level of positioned elements  Understanding stacking context Each positioned element creates a stacking context. Elements in different stacking contexts are overlapped according to the stacking order of their containers. For example, there is no way for #A1 and #A2 (children of #A) to be placed over #B without increasing the z-index of #A. 6
  • 7. Positioning Live Demo positioning-rules.html
  • 8. Inline element positioning  vertical-align: sets the vertical-alignment of an inline element, according to the line height  Values: baseline, sub, super, top, text-top, middle, bottom, text-bottom or numeric  Also used for content of table cells (which apply middle alignment by default) 8
  • 9. Alignment and Z-Index Live Demo alignments-and-z-index-rules.html
  • 11. Float  float: the element “floats” to one side  left: places the element on the left and following content on the right  right: places the element on the right and following content on the left  floated elements should come before the content that will wrap around them in the code  margins of floated elements do not collapse  floated inline elements can apply height 11
  • 12. Float (2)  How floated elements are positioned 12
  • 13. Clear  clear  Sets the sides of the element where other floating elements are NOT allowed  Used to "drop" elements below floated ones or expand a container, which contains only floated children  Possible values: left, right, both  Clearing floats  additional element (<div>) with a clear style 13
  • 14. Clear (2)  Clearing floats (continued)  :after { content: ""; display: block; clear: both; height: 0; }  Triggering hasLayout in IE expands a container of floated elements  display: inline-block;  zoom: 1; 14
  • 15. Floating Elements Live Demo float-rules.html
  • 17. Opacity  opacity: specifies the opacity of the element  Floating point number from 0 to 1  For old Mozilla browsers use –moz-opacity  For IE use filter:alpha(opacity=value) where value is from 0 to 100; also, "binary and script behaviors" must be enabled and hasLayout must be triggered, e.g. with zoom:1 17
  • 18. Opacity Live Demo opacity-rule.html
  • 20. Visibility  visibility  Determines whether the element is visible  hidden: element is not rendered, but still occupies place on the page (similar to opacity:0)  visible: element is rendered normally 20
  • 21. Visibility Live Demo visibility-rule.html
  • 23. Display  display: controls the displayof the element and the way it is rendered and if breaks should be placed before and after the element  inline: no breaks are placed before and after (<span> is an inline element)  block: breaks are placed before AND after the element (<div> is a block element) 23
  • 24. Display (2)  display: controls the displayof the element and the way it is rendered and if breaks should be placed before and after the element  none: element is hidden and its dimensions are not used to calculate the surrounding elements rendering (differs from visibility: hidden!)  There are some more possible values, but not all browsers support them  Specific displays like table-cell and table-row 24
  • 25. Display Live Demo display-rule.html
  • 26. CSS – Part II Questions? http://frontendcourse.telerik.com
  • 27. Homework 1. Create the following Web page using HTML and external CSS. Using tables, inline styles and deprecated tags is not allowed. 27
  • 28. Homework (2) 2. Create the following Web page using external CSS styles. Buttons should consist of PNG images with text over them. 28
  • 29. Homework (3) 3. Create the following Web page using HTML with external CSS file. Note that the images should be PNG with transparent background. 29
  • 30. Homework (4) 4. Given the picture below create the Web site  Use CSS and HTML 5 30
  • 31. Homework (5) 5. Create the following HTML 5 Page  Do it without tables 31