SlideShare a Scribd company logo
1 of 31
CSS Layout


Doncho Minkov
Technical Trainer
http://minkov.it
Telerik Web Design Course
html5course.telerik.com
Table of Contents
   Positioning
     Positioning inline elements
   Floating
     Left and right
     Clearing
 Opacity
 Visibility

 Display




                                                    2
Positioning
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 display of 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 display of 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 Layout




http://html5course.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)
1.   Create the following
     Web page using
     external CSS styles.
     Buttons should consist
     of PNG images with
     text over them.




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




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




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




                                               31

More Related Content

What's hot

CSS - Text Properties
CSS - Text PropertiesCSS - Text Properties
CSS - Text Properties
hstryk
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
apnwebdev
 

What's hot (20)

html-table
html-tablehtml-table
html-table
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
CSS - Text Properties
CSS - Text PropertiesCSS - Text Properties
CSS - Text Properties
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
 
HTML iframe
HTML iframeHTML iframe
HTML iframe
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4
 
CSS Introduction
CSS IntroductionCSS Introduction
CSS Introduction
 
Web Development using HTML & CSS
Web Development using HTML & CSSWeb Development using HTML & CSS
Web Development using HTML & CSS
 
Css
CssCss
Css
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
 
Functions in javascript
Functions in javascriptFunctions in javascript
Functions in javascript
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Css
CssCss
Css
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 

Similar to 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
 

Similar to CSS Layout (20)

Css layout
Css layoutCss layout
Css layout
 
Chapter05-Presentation.pptx
Chapter05-Presentation.pptxChapter05-Presentation.pptx
Chapter05-Presentation.pptx
 
CSS_Dibbo
CSS_DibboCSS_Dibbo
CSS_Dibbo
 
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
 
CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)
 
Displaying.pptx
Displaying.pptxDisplaying.pptx
Displaying.pptx
 
Advanced CSS.pptx
Advanced CSS.pptxAdvanced CSS.pptx
Advanced CSS.pptx
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
 
CSS3 Refresher
CSS3 RefresherCSS3 Refresher
CSS3 Refresher
 
Floats
FloatsFloats
Floats
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
 
HTML5 and CSS3
HTML5 and CSS3HTML5 and CSS3
HTML5 and CSS3
 
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
 
WDES106 CSS Advanced Part 1
WDES106 CSS Advanced Part 1WDES106 CSS Advanced Part 1
WDES106 CSS Advanced Part 1
 
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)
 
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
 
leggi
leggileggi
leggi
 
HTML and CSS part 3
HTML and CSS part 3HTML and CSS part 3
HTML and CSS part 3
 

More from Doncho Minkov

More from Doncho Minkov (20)

Web Design Concepts
Web Design ConceptsWeb Design Concepts
Web Design Concepts
 
Web design Tools
Web design ToolsWeb design Tools
Web design Tools
 
HTML 5
HTML 5HTML 5
HTML 5
 
HTML 5 Tables and Forms
HTML 5 Tables and FormsHTML 5 Tables and Forms
HTML 5 Tables and Forms
 
CSS Overview
CSS OverviewCSS Overview
CSS Overview
 
CSS Presentation
CSS PresentationCSS Presentation
CSS Presentation
 
CSS 3
CSS 3CSS 3
CSS 3
 
Adobe Photoshop
Adobe PhotoshopAdobe Photoshop
Adobe Photoshop
 
Slice and Dice
Slice and DiceSlice and Dice
Slice and Dice
 
Introduction to XAML and WPF
Introduction to XAML and WPFIntroduction to XAML and WPF
Introduction to XAML and WPF
 
WPF Layout Containers
WPF Layout ContainersWPF Layout Containers
WPF Layout Containers
 
WPF Controls
WPF ControlsWPF Controls
WPF Controls
 
WPF Templating and Styling
WPF Templating and StylingWPF Templating and Styling
WPF Templating and Styling
 
WPF Graphics and Animations
WPF Graphics and AnimationsWPF Graphics and Animations
WPF Graphics and Animations
 
Simple Data Binding
Simple Data BindingSimple Data Binding
Simple Data Binding
 
Complex Data Binding
Complex Data BindingComplex Data Binding
Complex Data Binding
 
WPF Concepts
WPF ConceptsWPF Concepts
WPF Concepts
 
Model View ViewModel
Model View ViewModelModel View ViewModel
Model View ViewModel
 
WPF and Databases
WPF and DatabasesWPF and Databases
WPF and Databases
 
Introduction to Cross-platform Mobile Development Course
Introduction to Cross-platform Mobile Development CourseIntroduction to Cross-platform Mobile Development Course
Introduction to Cross-platform Mobile Development Course
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

CSS Layout

  • 1. CSS Layout Doncho Minkov Technical Trainer http://minkov.it 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 display of 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 display of 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
  • 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) 1. Create the following Web page using external CSS styles. Buttons should consist of PNG images with text over them. 28
  • 29. Homework (3) 1. 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) 1. Given the picture below create the Web site  Use CSS and HTML 5 30
  • 31. Homework (5) 1. Create the following HTML 5 Page  Do it without tables 31