SlideShare a Scribd company logo
CSS POSITIONING
& FLOATING
Advanced CSS techniques
how to position
1. Determine the method of positioning
      position:static;
      position:relative;
      position:absolute;
      position:fixed;

2. Specify the actual numerical values for
   its exact coordinates
      left:100px;    right:200px;
      top:50px;      bottom:5px;
POSITION: STATIC
• Default setting
• Positions itself according to the “normal
  flow” (order of declaration of elements
  in the HTML, etc)
• rules like left:10px;   top:30%; do not
  work
POSITION: RELATIVE
• Positions itself according to its default
    position
• Still follows the “normal flow”, maintains
    its previous space occupied
•   position:relative;
    top:50px; left:50px;
    box moves 50px down (away from the top
    edge), and 50px to the right (away from
    the left edge) from its previous position
position: absolute
• Element is removed/lifted from the
    container element, and positioned
    according to the edges of the canvas
•   position:absolute;
    top:0px; left:0px;
    box is attached to the upper-left corner of
    the canvas, not the container element
position: fixed
• Positioned according to the browser
• Remains fixed, does not scroll with the
    content
•   position:fixed;
    left:0; top:0;
    box attaches to the top-left corner, and
    does not move with the content when
    scrolled
floating

• Floating makes objects line up in one
  side of its container element, and
  allowing other elements to flow around
  it
• First used to wrap text around images
More on Floating

• Objects will only float as far as its
  container element
• When floating block-elements, always
  define a width
floating boxes
• Fix dimensions
 .sample {            .samplethree {
 background:yellow;   background:orange;
 width:400px;         width:400px;
 height:100px;        height:80px;
 }                    }
 .sampletwo {
 background:pink;
 width:400px;
 height:60px;
 }
Floating with text
• Add float property to the last box
  .samplethree {
  background-color:orange;
  width:400px;
  height:80px;
  float:left;
  }
floating boxes
•   Add float property   .sampletwo {
                         background:pink;
    also to the first
                         width:400px;
    two                  height:100px;
                         float:left
    .sample {            }
    background:yellow;
    width:400px;
    height:100px;
    float:left;
    }
Float Direction
•   Change all to        width:400px;
                         height:60px;
    float:right
                         float:right
    .sample {
                         }
    background:yellow;
                         .samplethree {
    width:400px;
                         background:orange;
    height:100px;
                         width:400px;
    float:right;
                         height:80px;
    }
                         float:right
    .sampletwo {
                         }
    background:pink;
Clear property
• Clearing an object will turn-off the
  floating, thus it will appear below an
  element that is floated in that direction
  clear:left;
  clear:right;
  clear:both;
Clear in action
•   Float only the first   width:400px;
                           height:60px;
    box
    .sample {              float:right;
    background:yellow;     }
    width:400px;           .samplethree {
    height:100px;          background:orange;
    float:right;           width:400px;
    }                      height:80px;
    .sampletwo {           float:right;
    background:pink;       }
Clear in action
•   Add clear to the     width:400px;
                         height:60px;
    pink box
    .sample {            clear:right;
    background:yellow;   }
    width:400px;         .samplethree {
    height:100px;        background:orange;
    float:right;         width:400px;
    }                    height:80px;
    .sampletwo {         }
    background:pink;

More Related Content

What's hot

Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptWeb front end development introduction to html css and javascript
Web front end development introduction to html css and javascript
Marc Huang
 
HTML Block and Inline Elements
HTML Block and Inline ElementsHTML Block and Inline Elements
HTML Block and Inline Elements
Webtech Learning
 
Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4
Naresh Sharma
 
Css
CssCss
CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong? CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong?
Russ Weakley
 
Css pseudo-classes
Css pseudo-classesCss pseudo-classes
Css pseudo-classes
Webtech Learning
 
Page layout with css
Page layout with cssPage layout with css
Page layout with css
Er. Nawaraj Bhandari
 
CSS Position and it’s values
CSS Position and it’s valuesCSS Position and it’s values
CSS Position and it’s values
Gunjan Tulsiani
 
5.1 css box model
5.1 css box model5.1 css box model
5.1 css box modelBulldogs83
 
CSS Introduction
CSS IntroductionCSS Introduction
CSS Introduction
Swati Sharma
 
JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
Jeff Fox
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
Rachel Andrew
 
jQuery
jQueryjQuery
jQuery
Jay Poojara
 

What's hot (20)

CSS
CSSCSS
CSS
 
Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptWeb front end development introduction to html css and javascript
Web front end development introduction to html css and javascript
 
CSS Lists and Tables
CSS Lists and TablesCSS Lists and Tables
CSS Lists and Tables
 
HTML Block and Inline Elements
HTML Block and Inline ElementsHTML Block and Inline Elements
HTML Block and Inline Elements
 
Css font properties
Css font propertiesCss font properties
Css font properties
 
Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4
 
Css
CssCss
Css
 
CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong? CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong?
 
Css pseudo-classes
Css pseudo-classesCss pseudo-classes
Css pseudo-classes
 
Page layout with css
Page layout with cssPage layout with css
Page layout with css
 
LINKING IN HTML
LINKING IN HTMLLINKING IN HTML
LINKING IN HTML
 
CSS Position and it’s values
CSS Position and it’s valuesCSS Position and it’s values
CSS Position and it’s values
 
5.1 css box model
5.1 css box model5.1 css box model
5.1 css box model
 
CSS Introduction
CSS IntroductionCSS Introduction
CSS Introduction
 
JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
 
Css tables
Css tablesCss tables
Css tables
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
 
jQuery
jQueryjQuery
jQuery
 
Css backgrounds
Css   backgroundsCss   backgrounds
Css backgrounds
 

Viewers also liked

Css Positioning Elements
Css Positioning ElementsCss Positioning Elements
Css Positioning Elementssanjay2211
 
CSS Positioning
CSS PositioningCSS Positioning
Shaping Up With CSS
Shaping Up With CSSShaping Up With CSS
Shaping Up With CSSsdireland
 
HTML&CSS 6 - Advanced CSS
HTML&CSS 6 - Advanced CSSHTML&CSS 6 - Advanced CSS
HTML&CSS 6 - Advanced CSS
Dinis Correia
 
CSS Layouting #5 : Position
CSS Layouting #5 : PositionCSS Layouting #5 : Position
CSS Layouting #5 : Position
Sandhika Galih
 
CSS Layout
CSS LayoutCSS Layout
CSS Layout
景智 張
 
1 07-2-css floats-and_positioning
1 07-2-css floats-and_positioning1 07-2-css floats-and_positioning
1 07-2-css floats-and_positioningapnwebdev
 
Lesson 108 23 aug13-1430-ay
Lesson 108 23 aug13-1430-ayLesson 108 23 aug13-1430-ay
Lesson 108 23 aug13-1430-ayCodecademy Ren
 
SVG - Scalable Vector Graphic
SVG - Scalable Vector GraphicSVG - Scalable Vector Graphic
SVG - Scalable Vector Graphic
Akila Iroshan
 
5 domain name worksheet
5   domain name worksheet5   domain name worksheet
5 domain name worksheet
viet nghiem
 
CSS font-stacks
CSS font-stacksCSS font-stacks
CSS font-stacks
Russ Weakley
 
Floating
FloatingFloating
Floating
Danielle Larson
 
The Box Model
The Box ModelThe Box Model
The Box Modelsdireland
 
Understanding the flex layout
Understanding the flex layoutUnderstanding the flex layout
Understanding the flex layout
Barak Drechsler
 
Intro to OOCSS Workshop
Intro to OOCSS WorkshopIntro to OOCSS Workshop
Intro to OOCSS Workshop
Julie Cameron
 
Anatomy Of A Domain Name and URL
Anatomy Of A Domain Name and URLAnatomy Of A Domain Name and URL
Anatomy Of A Domain Name and URL
Andy Wibbels
 
CSS3 filterとtransformをtransition, animationでアニメーション
CSS3 filterとtransformをtransition, animationでアニメーションCSS3 filterとtransformをtransition, animationでアニメーション
CSS3 filterとtransformをtransition, animationでアニメーション
Hiroaki Okubo
 
Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02
Hatem Mahmoud
 
Purchase Your Domain Name
Purchase Your Domain NamePurchase Your Domain Name
Purchase Your Domain Name
Courtney Engle
 

Viewers also liked (20)

Css Positioning Elements
Css Positioning ElementsCss Positioning Elements
Css Positioning Elements
 
CSS Positioning
CSS PositioningCSS Positioning
CSS Positioning
 
Shaping Up With CSS
Shaping Up With CSSShaping Up With CSS
Shaping Up With CSS
 
HTML&CSS 6 - Advanced CSS
HTML&CSS 6 - Advanced CSSHTML&CSS 6 - Advanced CSS
HTML&CSS 6 - Advanced CSS
 
CSS Layouting #5 : Position
CSS Layouting #5 : PositionCSS Layouting #5 : Position
CSS Layouting #5 : Position
 
CSS Layout
CSS LayoutCSS Layout
CSS Layout
 
1 07-2-css floats-and_positioning
1 07-2-css floats-and_positioning1 07-2-css floats-and_positioning
1 07-2-css floats-and_positioning
 
Lesson 108 23 aug13-1430-ay
Lesson 108 23 aug13-1430-ayLesson 108 23 aug13-1430-ay
Lesson 108 23 aug13-1430-ay
 
SVG - Scalable Vector Graphic
SVG - Scalable Vector GraphicSVG - Scalable Vector Graphic
SVG - Scalable Vector Graphic
 
Layout
LayoutLayout
Layout
 
5 domain name worksheet
5   domain name worksheet5   domain name worksheet
5 domain name worksheet
 
CSS font-stacks
CSS font-stacksCSS font-stacks
CSS font-stacks
 
Floating
FloatingFloating
Floating
 
The Box Model
The Box ModelThe Box Model
The Box Model
 
Understanding the flex layout
Understanding the flex layoutUnderstanding the flex layout
Understanding the flex layout
 
Intro to OOCSS Workshop
Intro to OOCSS WorkshopIntro to OOCSS Workshop
Intro to OOCSS Workshop
 
Anatomy Of A Domain Name and URL
Anatomy Of A Domain Name and URLAnatomy Of A Domain Name and URL
Anatomy Of A Domain Name and URL
 
CSS3 filterとtransformをtransition, animationでアニメーション
CSS3 filterとtransformをtransition, animationでアニメーションCSS3 filterとtransformをtransition, animationでアニメーション
CSS3 filterとtransformをtransition, animationでアニメーション
 
Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02
 
Purchase Your Domain Name
Purchase Your Domain NamePurchase Your Domain Name
Purchase Your Domain Name
 

More from Gerson Abesamis

YMSAT Project Proposal Form
YMSAT Project Proposal FormYMSAT Project Proposal Form
YMSAT Project Proposal Form
Gerson Abesamis
 
YMSAT Student Primer
YMSAT Student PrimerYMSAT Student Primer
YMSAT Student Primer
Gerson Abesamis
 
960 Grid System
960 Grid System960 Grid System
960 Grid System
Gerson Abesamis
 
Photography Orientation 11-12
Photography Orientation 11-12Photography Orientation 11-12
Photography Orientation 11-12Gerson Abesamis
 
WebDev2 Orientation 11-12
WebDev2 Orientation 11-12WebDev2 Orientation 11-12
WebDev2 Orientation 11-12Gerson Abesamis
 
Pinhole photography vale
Pinhole photography valePinhole photography vale
Pinhole photography valeGerson Abesamis
 
CSS Box Model and Dimensions
CSS Box Model and DimensionsCSS Box Model and Dimensions
CSS Box Model and DimensionsGerson Abesamis
 
Information Architecture
Information ArchitectureInformation Architecture
Information ArchitectureGerson Abesamis
 

More from Gerson Abesamis (20)

YMSAT Project Proposal Form
YMSAT Project Proposal FormYMSAT Project Proposal Form
YMSAT Project Proposal Form
 
YMSAT Student Primer
YMSAT Student PrimerYMSAT Student Primer
YMSAT Student Primer
 
Final Project
Final ProjectFinal Project
Final Project
 
960 Grid System
960 Grid System960 Grid System
960 Grid System
 
CSS Box Model
CSS Box ModelCSS Box Model
CSS Box Model
 
Photography Orientation 11-12
Photography Orientation 11-12Photography Orientation 11-12
Photography Orientation 11-12
 
WebDev2 Orientation 11-12
WebDev2 Orientation 11-12WebDev2 Orientation 11-12
WebDev2 Orientation 11-12
 
Photography Class 11-12
Photography Class 11-12Photography Class 11-12
Photography Class 11-12
 
Prewar report
Prewar reportPrewar report
Prewar report
 
Typo Graphics
Typo GraphicsTypo Graphics
Typo Graphics
 
Web Typography
Web TypographyWeb Typography
Web Typography
 
Typographic Contrast
Typographic ContrastTypographic Contrast
Typographic Contrast
 
WebDev Template Finals
WebDev Template FinalsWebDev Template Finals
WebDev Template Finals
 
Pinhole photography vale
Pinhole photography valePinhole photography vale
Pinhole photography vale
 
CSS Box Model and Dimensions
CSS Box Model and DimensionsCSS Box Model and Dimensions
CSS Box Model and Dimensions
 
Interface Design
Interface DesignInterface Design
Interface Design
 
CSS Refresher
CSS RefresherCSS Refresher
CSS Refresher
 
Intro to HTML
Intro to HTMLIntro to HTML
Intro to HTML
 
Information Architecture
Information ArchitectureInformation Architecture
Information Architecture
 
Site Dev't Team
Site Dev't TeamSite Dev't Team
Site Dev't Team
 

Css positioning

  • 2. how to position 1. Determine the method of positioning position:static; position:relative; position:absolute; position:fixed; 2. Specify the actual numerical values for its exact coordinates left:100px; right:200px; top:50px; bottom:5px;
  • 3. POSITION: STATIC • Default setting • Positions itself according to the “normal flow” (order of declaration of elements in the HTML, etc) • rules like left:10px; top:30%; do not work
  • 4.
  • 5. POSITION: RELATIVE • Positions itself according to its default position • Still follows the “normal flow”, maintains its previous space occupied • position:relative; top:50px; left:50px; box moves 50px down (away from the top edge), and 50px to the right (away from the left edge) from its previous position
  • 6.
  • 7. position: absolute • Element is removed/lifted from the container element, and positioned according to the edges of the canvas • position:absolute; top:0px; left:0px; box is attached to the upper-left corner of the canvas, not the container element
  • 8.
  • 9. position: fixed • Positioned according to the browser • Remains fixed, does not scroll with the content • position:fixed; left:0; top:0; box attaches to the top-left corner, and does not move with the content when scrolled
  • 10.
  • 11.
  • 12. floating • Floating makes objects line up in one side of its container element, and allowing other elements to flow around it • First used to wrap text around images
  • 13.
  • 14. More on Floating • Objects will only float as far as its container element • When floating block-elements, always define a width
  • 15.
  • 16. floating boxes • Fix dimensions .sample { .samplethree { background:yellow; background:orange; width:400px; width:400px; height:100px; height:80px; } } .sampletwo { background:pink; width:400px; height:60px; }
  • 17.
  • 18. Floating with text • Add float property to the last box .samplethree { background-color:orange; width:400px; height:80px; float:left; }
  • 19.
  • 20. floating boxes • Add float property .sampletwo { background:pink; also to the first width:400px; two height:100px; float:left .sample { } background:yellow; width:400px; height:100px; float:left; }
  • 21.
  • 22. Float Direction • Change all to width:400px; height:60px; float:right float:right .sample { } background:yellow; .samplethree { width:400px; background:orange; height:100px; width:400px; float:right; height:80px; } float:right .sampletwo { } background:pink;
  • 23.
  • 24. Clear property • Clearing an object will turn-off the floating, thus it will appear below an element that is floated in that direction clear:left; clear:right; clear:both;
  • 25.
  • 26. Clear in action • Float only the first width:400px; height:60px; box .sample { float:right; background:yellow; } width:400px; .samplethree { height:100px; background:orange; float:right; width:400px; } height:80px; .sampletwo { float:right; background:pink; }
  • 27.
  • 28. Clear in action • Add clear to the width:400px; height:60px; pink box .sample { clear:right; background:yellow; } width:400px; .samplethree { height:100px; background:orange; float:right; width:400px; } height:80px; .sampletwo { } background:pink;