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

What's hot (20)

HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
HTML5: features with examples
HTML5: features with examplesHTML5: features with examples
HTML5: features with examples
 
Angular Directives
Angular DirectivesAngular Directives
Angular Directives
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
 
Bootstrap 4 ppt
Bootstrap 4 pptBootstrap 4 ppt
Bootstrap 4 ppt
 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Html
HtmlHtml
Html
 
Introducing Cascading Style Sheets
Introducing Cascading Style SheetsIntroducing Cascading Style Sheets
Introducing Cascading Style Sheets
 
Bootstrap 5 ppt
Bootstrap 5 pptBootstrap 5 ppt
Bootstrap 5 ppt
 
CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations
 
Jquery
JqueryJquery
Jquery
 
Css pseudo-classes
Css pseudo-classesCss pseudo-classes
Css pseudo-classes
 
Angular Best Practices - Perfomatix
Angular Best Practices - PerfomatixAngular Best Practices - Perfomatix
Angular Best Practices - Perfomatix
 
Introduction to html 5
Introduction to html 5Introduction to html 5
Introduction to html 5
 
HTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts BasicsHTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts Basics
 
CSS ppt
CSS pptCSS ppt
CSS ppt
 

Similar to CSS Layout

Css layout
Css layoutCss layout
Css layoutclub23
 
Chapter05-Presentation.pptx
Chapter05-Presentation.pptxChapter05-Presentation.pptx
Chapter05-Presentation.pptxssuserf3db48
 
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 2Barak Drechsler
 
Web Design & Development - Session 3
Web Design & Development - Session 3Web Design & Development - Session 3
Web Design & Development - Session 3Shahrzad Peyman
 
CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)Rafi Haidari
 
Advanced CSS.pptx
Advanced CSS.pptxAdvanced CSS.pptx
Advanced CSS.pptxDiyonaVas
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvZahouAmel1
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101Ashraf Hamdy
 
WDES106 CSS Advanced Part 1
WDES106 CSS Advanced Part 1WDES106 CSS Advanced Part 1
WDES106 CSS Advanced Part 1Gene Babon
 
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)Zoe Gillenwater
 
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 1Barak Drechsler
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksAmit Tyagi
 

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
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 

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

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
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
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 

Recently uploaded (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
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
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 

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