SlideShare a Scribd company logo
1 of 60
Download to read offline
WEB LAYOUT 
22-3376 Web Design 2 // Columbia College Chicago
QUIZ REVIEW 
color: #444 
font-family: "Times New Roman", Georgia, serif 
font-size: 16px (define in px, em, or %) 
font-style: italic 
font-variant: small-caps 
font-weight: bold (or by number, 300, 400, 700, 800) 
letter-spacing: .02em 
line-height: 1.6; (relative to whatever your type size is) 
text-align: left; 
text-transform: uppercase;
ASSIGNMENTS 
Upload your assignments to your server 
!
QUIZ 
Open a plain text document 
! 
Write the markup to recreate the image 
! 
! 
http://lms.colum.edu/
PROJECT VOTING 
Please hand in your ballot by the end of class
The Box Model
There are five basic properties for defining your “boxes”: 
display 
width and height 
padding 
margins 
border
CSS Box Model 
All HTML elements can be 
considered as boxes or 
blocks. In CSS, the term 
"box model" is used when 
talking about design and 
layout. 
The CSS box model is 
essentially a box that wraps 
around HTML elements, and 
it consists of: margins, 
borders, padding, and the 
actual content. 
! 
Inspect Element 3d view in Firefox
Total dimensions 
The actual width or height of any 
object is the total of the content 
width, padding, borders, and 
margins. 
.size-me { 
width: 200px; 
padding: 10px; 
border: 2px; 
margin: 20px; 
}" 
The actual width: 254px 
content: 200px 
padding-left: 10px 
padding-right: 10px 
border-right: 2px 
border-left: 2px 
margin-right: 20px 
margin-left: 20px 
! 
!
Tags: HTML Sectioning Elements
header 
footer 
nav 
section 
article 
aside
Class Exercise 
! 
1 Boxes
Defining padding & margins 
You can set the padding and margin properties of any 
element in css. 
Margin and padding dimensions can be also pixels (px), 
ems, or percentage (%). 
.space-me { 
padding: 10px; 
margin-bottom: 20px; 
} 
! 
! 
!
Defining padding & margins 
While you can add padding and margins to inline 
elements, not all of your properties will apply (vertical 
spacing, see below). 
! 
! 
!
Collapsing margins 
Body 
Elements 
p 
br 
h1 – h6 
ul 
ol 
a 
img 
When two or more 
margins collapse, the 
resulting margin width 
is the maximum of the 
collapsing margins' 
widths. 
In the example below, 
box1 has a taller 
margin than box2, so 
only that margin will 
be used (not added 
together). 
! 
!
CSS Shorthand 
1 
2 
3 
4 
When setting sizes for padding, 
margins and borders, instead of this: 
.box { 
padding-top: 10px; 
padding-right: 15px; 
padding-bottom: 10px; 
padding-left: 15px; 
} 
Use this: 
.box { 
padding: 10px 15px 10px 15px; 
}" 
The values start at the top and go 
around the element clockwise. 
! 
!
CSS Shorthand 
1 
2 
1 
2 
If your top/bottom and left/right values 
are the same, you can shorten the 
declaration even more: 
.box { 
padding: 10px 15px; 
}" 
Where the first value is for the top and 
bottom, and the second is for left and 
right. 
! 
!
Defining borders 
You can create a border around any element with css; you 
can create the same border on each side, or customize the 
color, width and border style of each side. 
! 
There are 3 properties to define with each border: 
border-width: 1px; 
border-style: solid; (dotted, dashed, etc) 
border color: #666666; 
! 
! 
!
CSS Shorthand 
Borders can also be shortened, from this: 
.box { 
border-width: 1px; 
border-style: solid; 
border-color: #888888 
}" 
to this: 
.box { 
border: 1px solid #888888; 
}" 
Note that there is only a single space between each value, and 
they should follow the order shown above. 
! 
!
Defining borders 
h3 { 
border-bottom: 1px solid #444444; 
} 
! 
!
Class Exercise 
! 
2 Padding, Margins & Borders
Class Exercise 
! 
3 Defining Widths
Display property 
There are four values that you can give to the display property: 
display: block; 
display: inline; 
display: inline-block; 
display: none 
! 
Inline-block is a special value that allows an element to stay inline 
with its containing element, but allows you to control it’s 
dimensions as if it were a block element. 
display: none removes the element.
Display property 
By default, certain elements in your html have a display 
property of inline or block. 
Block elements takes up the full width available, and forces a 
line above and below. Examples include <p>, <div>, <ul>, 
<blockquote> and all headers. 
<div></div> 
<p></p> 
<ul></ul>
Display property 
Inline elements can be inserted within block elements or 
other inline elements and do no create additional space or 
line breaks. Examples include <img>, <em>, <strong>, 
<a>, and <span>. 
<p> 
<p></p> 
<p></p> 
<a></a> </p>
Defining dimension: width and height 
You can set the width and height of any element that has a 
display property of block or inline-block. 
As with type, you can set dimension in pixels (px), ems, or 
percentage (%). Setting any width with pixels is referred to as 
fixed-width, and setting width in ems or percentages is 
referred to as flexible-width. 
.size-me { 
width: 200px; 
height: 200px; 
} 
! 
!
Defining dimension: min- and max- 
Instead of absolutely defining the width and height of your 
elements, you can set minimum and maximum widths and 
heights. 
This allows you to resize elements based on the browser or 
their parent elements. The idea of creating flexible content 
that adjusts to the user’s browser/device is at the core of what 
is referred to as responsive design. 
.size-me { 
min-width: 200px; 
max-width: 100px; 
}"
Centered, Fixed-width Page 
! 
body { 
width: 960px; 
margin: 0 auto; 
}
Float and set 300px width on article element 
! 
! 
!
Defining dimension: min-width and max-width 
! 
! 
!
Defining dimension: min-height 
! 
! 
!
Defining dimension: change display property of anchors 
! 
! 
!
Clear the footer 
! 
! 
! 
! 
!
Clear the footer 
When you float an element, their containing element no 
longer recognizes their width or height (the are out of the 
“flow”). This becomes and issue if the floated content is 
taller than the containing element. There are several ways 
to fix this; the easiest way is to set the overflow property 
on the containing div to “auto”. 
.containing-div { 
overflow: auto 
}" 
! 
!
Make it responsive 
! 
@media only screen and (max-width: 767px) { 
body { 
width: 100%; 
} 
article { 
width: auto; 
margin: 20px; 
} 
h1 { 
padding: 0 20px; 
} 
}
Floats and Positioning
There are four basic declarations 
you can use to position your boxes: 
float: left (or right) 
position: relative 
position: fixed 
position: absolute
The normal flow & position:static 
Static positioning is the default – this is referred to as the 
“normal flow”. 
block boxes are positioned on a page one after the other 
(in the order they're written in the HTML). They start in the 
upper left of the containing box and stack from top to 
bottom. The distance between each box is defined by the 
margins with top and bottom margins collapsing into one 
another. 
! 
! 
! 
<div id=”header”></div> 
<div id=”content”></div> 
<ul id=”sidebar-nav”></ul>
float 
A floated element takes the element out of the normal 
flow and moves it to the far right or left of the containing 
element. Existing content will then flow around it. Floated 
elements should always have at least a width property. 
.photo { 
float: left; 
max-width: 150px; 
}" 
! 
!
Class Exercise 
! 
4 Float
Class Exercise 
! 
5 Two-Column layout
Class Exercise 
! 
6 Fixed/Flexible Hybrid Layout
Positioning Properties 
There are four values that you can give to the position property: 
! 
static Elements renders in order, as they appear in the document 
flow. This is default. 
relative The element is positioned relative to its static position, so 
“left:20” adds 20 pixels to the element’s LEFT position. 
absolute The element is positioned relative to its first positioned 
(not static) ancestor element (usually, the first parent with 
position:relative). 
fixed The element is positioned relative to the browser window.
Class Exercise 
! 
7 Positioning
boxes exercise 
.box { 
"" width: 300px; 
"" height: 300px; 
"" border: 1px solid #333; 
"" margin: 10px; 
"" display: inline-block; 
}" " 
.relative { 
"" position: relative; 
"" top: 50px; 
"" left: -50px; 
}" 
.fixed { 
"" position: fixed; 
"" bottom: 0; 
"" left: 0; 
}" 
! 
!
boxes exercise 
.box.absolute { 
"" position: relative; 
}" 
.box.absolute p { 
"" position: absolute; 
"" top: 0; 
"" right: 0; 
"" background: #444; 
"" padding: 10px; 
"" margin: 0; 
"" color: #fff; 
}" 
! 
! 
!
relative 
A relative positioned element moves the element out of 
it’s position in the normal flow, and allows you to move it 
“relative” to that location. The space taken by the original 
location is retained in the flow. 
.date { 
position: relative; 
top: 40px; 
left: -105px; 
}" 
! 
!
relative exercise 
! 
! 
.date { 
! 
position: relative; 
top: 40px; 
left: -105px; 
}" 
! 
!
fixed 
A fixed element is taken complete out of the document 
flow, and is positioned relative to the browser window. 
.create-change { 
position: fixed; 
bottom: 40px; 
right: 0; 
}" 
! 
!
fixed exercise 
! 
! 
.create-change { 
! 
position: fixed; 
bottom: 40px; 
right: 0; 
}" 
! 
!
absolute 
The element is positioned relative to its first positioned 
(not static) ancestor element. The element and its spacing 
are completely taken out of the flow. In the example 
below, the “.post” parent element is given a position 
value of relative, which lets us set it’s child element “.icon” 
within it. 
.post { 
position: relative; 
}" 
.icon { 
position: absolute; 
left: -60px; 
right: 0; 
}" 
! 
!
absolute exercise 
! 
! 
.post { 
! 
position: relative; 
}" 
.icon { 
position: absolute; 
left: -60px; 
right: 0; 
}" 
! 
!

More Related Content

What's hot

Div tag presentation
Div tag presentationDiv tag presentation
Div tag presentation
alyssa_lum11
 
Class Intro / HTML Basics
Class Intro / HTML BasicsClass Intro / HTML Basics
Class Intro / HTML Basics
Shawn Calvert
 
HTML CSS Best Practices
HTML CSS Best PracticesHTML CSS Best Practices
HTML CSS Best Practices
hoctudau
 
Intro to HTML and CSS - Class 2 Slides
Intro to HTML and CSS - Class 2 SlidesIntro to HTML and CSS - Class 2 Slides
Intro to HTML and CSS - Class 2 Slides
Heather Rock
 
HTML Foundations, pt 3: Forms
HTML Foundations, pt 3: FormsHTML Foundations, pt 3: Forms
HTML Foundations, pt 3: Forms
Shawn Calvert
 

What's hot (20)

Frontend Crash Course: HTML and CSS
Frontend Crash Course: HTML and CSSFrontend Crash Course: HTML and CSS
Frontend Crash Course: HTML and CSS
 
Div tag presentation
Div tag presentationDiv tag presentation
Div tag presentation
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
Css.html
Css.htmlCss.html
Css.html
 
Class Intro / HTML Basics
Class Intro / HTML BasicsClass Intro / HTML Basics
Class Intro / HTML Basics
 
Presentation on html, css
Presentation on html, cssPresentation on html, css
Presentation on html, css
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
 
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
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
 
HTML Email
HTML EmailHTML Email
HTML Email
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
HTML/CSS Crash Course (april 4 2017)
HTML/CSS Crash Course (april 4 2017)HTML/CSS Crash Course (april 4 2017)
HTML/CSS Crash Course (april 4 2017)
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
HTML CSS Best Practices
HTML CSS Best PracticesHTML CSS Best Practices
HTML CSS Best Practices
 
HTML CSS Basics
HTML CSS BasicsHTML CSS Basics
HTML CSS Basics
 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01
 
Intro to HTML and CSS - Class 2 Slides
Intro to HTML and CSS - Class 2 SlidesIntro to HTML and CSS - Class 2 Slides
Intro to HTML and CSS - Class 2 Slides
 
HTML Foundations, pt 3: Forms
HTML Foundations, pt 3: FormsHTML Foundations, pt 3: Forms
HTML Foundations, pt 3: Forms
 
HTML & CSS Workshop Notes
HTML & CSS Workshop NotesHTML & CSS Workshop Notes
HTML & CSS Workshop Notes
 

Viewers also liked (9)

Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
User Centered Design
User Centered DesignUser Centered Design
User Centered Design
 
Introduction to Responsive Web Design
Introduction to Responsive Web DesignIntroduction to Responsive Web Design
Introduction to Responsive Web Design
 
Web Design Process
Web Design ProcessWeb Design Process
Web Design Process
 
10 Usability & UX Guidelines
10 Usability & UX Guidelines10 Usability & UX Guidelines
10 Usability & UX Guidelines
 
Basics of Web Navigation
Basics of Web NavigationBasics of Web Navigation
Basics of Web Navigation
 
Intro to Javascript and jQuery
Intro to Javascript and jQueryIntro to Javascript and jQuery
Intro to Javascript and jQuery
 
Creating Images for the Web
Creating Images for the WebCreating Images for the Web
Creating Images for the Web
 
Usability and User Experience
Usability and User ExperienceUsability and User Experience
Usability and User Experience
 

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

Similar to Web Layout (20)

Lecture-8.pptx
Lecture-8.pptxLecture-8.pptx
Lecture-8.pptx
 
card flip
card flip card flip
card flip
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
 
Web Design Course: CSS lecture 4
Web Design Course: CSS  lecture 4Web Design Course: CSS  lecture 4
Web Design Course: CSS lecture 4
 
CSS for basic learner
CSS for basic learnerCSS for basic learner
CSS for basic learner
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Html frames
Html framesHtml frames
Html frames
 
Class 10
Class 10Class 10
Class 10
 
CSS and CSS3
CSS and CSS3CSS and CSS3
CSS and CSS3
 
The Creative New World of CSS
The Creative New World of CSSThe Creative New World of CSS
The Creative New World of CSS
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
Basic css
Basic cssBasic css
Basic css
 
CSS
CSSCSS
CSS
 
CSS Cascade Style Sheet
CSS Cascade Style SheetCSS Cascade Style Sheet
CSS Cascade Style Sheet
 
GOTO Berlin - You can use CSS for that
GOTO Berlin - You can use CSS for thatGOTO Berlin - You can use CSS for that
GOTO Berlin - You can use CSS for that
 
Deep Dive into Line-Height
Deep Dive into Line-HeightDeep Dive into Line-Height
Deep Dive into Line-Height
 
CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)
 
Css training
Css trainingCss training
Css training
 
CSS3 notes
CSS3 notesCSS3 notes
CSS3 notes
 
Css 101
Css 101Css 101
Css 101
 

More from Shawn Calvert (11)

Web Design I Syllabus 22 3375-03
Web Design I Syllabus 22 3375-03Web Design I Syllabus 22 3375-03
Web Design I Syllabus 22 3375-03
 
HTML Foundations, part 1
HTML Foundations, part 1HTML Foundations, part 1
HTML Foundations, part 1
 
Web Design 1: Introductions
Web Design 1: IntroductionsWeb Design 1: Introductions
Web Design 1: Introductions
 
22-3530, Photo Communications Syllabus
22-3530, Photo Communications Syllabus22-3530, Photo Communications Syllabus
22-3530, Photo Communications Syllabus
 
An Overview of Stock Photography
An Overview of Stock PhotographyAn Overview of Stock Photography
An Overview of Stock Photography
 
Color Photography
Color PhotographyColor Photography
Color Photography
 
PSA posters
PSA postersPSA posters
PSA posters
 
Composition & Light
Composition & LightComposition & Light
Composition & Light
 
of Pixels and Bits
of Pixels and Bitsof Pixels and Bits
of Pixels and Bits
 
Camera basics
Camera basics Camera basics
Camera basics
 
Typography I syllabus
Typography I syllabusTypography I syllabus
Typography I syllabus
 

Web Layout

  • 1. WEB LAYOUT 22-3376 Web Design 2 // Columbia College Chicago
  • 2. QUIZ REVIEW color: #444 font-family: "Times New Roman", Georgia, serif font-size: 16px (define in px, em, or %) font-style: italic font-variant: small-caps font-weight: bold (or by number, 300, 400, 700, 800) letter-spacing: .02em line-height: 1.6; (relative to whatever your type size is) text-align: left; text-transform: uppercase;
  • 3. ASSIGNMENTS Upload your assignments to your server !
  • 4. QUIZ Open a plain text document ! Write the markup to recreate the image ! ! http://lms.colum.edu/
  • 5. PROJECT VOTING Please hand in your ballot by the end of class
  • 7. There are five basic properties for defining your “boxes”: display width and height padding margins border
  • 8. CSS Box Model All HTML elements can be considered as boxes or blocks. In CSS, the term "box model" is used when talking about design and layout. The CSS box model is essentially a box that wraps around HTML elements, and it consists of: margins, borders, padding, and the actual content. ! Inspect Element 3d view in Firefox
  • 9. Total dimensions The actual width or height of any object is the total of the content width, padding, borders, and margins. .size-me { width: 200px; padding: 10px; border: 2px; margin: 20px; }" The actual width: 254px content: 200px padding-left: 10px padding-right: 10px border-right: 2px border-left: 2px margin-right: 20px margin-left: 20px ! !
  • 11. header footer nav section article aside
  • 12. Class Exercise ! 1 Boxes
  • 13. Defining padding & margins You can set the padding and margin properties of any element in css. Margin and padding dimensions can be also pixels (px), ems, or percentage (%). .space-me { padding: 10px; margin-bottom: 20px; } ! ! !
  • 14. Defining padding & margins While you can add padding and margins to inline elements, not all of your properties will apply (vertical spacing, see below). ! ! !
  • 15. Collapsing margins Body Elements p br h1 – h6 ul ol a img When two or more margins collapse, the resulting margin width is the maximum of the collapsing margins' widths. In the example below, box1 has a taller margin than box2, so only that margin will be used (not added together). ! !
  • 16. CSS Shorthand 1 2 3 4 When setting sizes for padding, margins and borders, instead of this: .box { padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; } Use this: .box { padding: 10px 15px 10px 15px; }" The values start at the top and go around the element clockwise. ! !
  • 17. CSS Shorthand 1 2 1 2 If your top/bottom and left/right values are the same, you can shorten the declaration even more: .box { padding: 10px 15px; }" Where the first value is for the top and bottom, and the second is for left and right. ! !
  • 18. Defining borders You can create a border around any element with css; you can create the same border on each side, or customize the color, width and border style of each side. ! There are 3 properties to define with each border: border-width: 1px; border-style: solid; (dotted, dashed, etc) border color: #666666; ! ! !
  • 19. CSS Shorthand Borders can also be shortened, from this: .box { border-width: 1px; border-style: solid; border-color: #888888 }" to this: .box { border: 1px solid #888888; }" Note that there is only a single space between each value, and they should follow the order shown above. ! !
  • 20. Defining borders h3 { border-bottom: 1px solid #444444; } ! !
  • 21. Class Exercise ! 2 Padding, Margins & Borders
  • 22. Class Exercise ! 3 Defining Widths
  • 23.
  • 24. Display property There are four values that you can give to the display property: display: block; display: inline; display: inline-block; display: none ! Inline-block is a special value that allows an element to stay inline with its containing element, but allows you to control it’s dimensions as if it were a block element. display: none removes the element.
  • 25. Display property By default, certain elements in your html have a display property of inline or block. Block elements takes up the full width available, and forces a line above and below. Examples include <p>, <div>, <ul>, <blockquote> and all headers. <div></div> <p></p> <ul></ul>
  • 26. Display property Inline elements can be inserted within block elements or other inline elements and do no create additional space or line breaks. Examples include <img>, <em>, <strong>, <a>, and <span>. <p> <p></p> <p></p> <a></a> </p>
  • 27. Defining dimension: width and height You can set the width and height of any element that has a display property of block or inline-block. As with type, you can set dimension in pixels (px), ems, or percentage (%). Setting any width with pixels is referred to as fixed-width, and setting width in ems or percentages is referred to as flexible-width. .size-me { width: 200px; height: 200px; } ! !
  • 28. Defining dimension: min- and max- Instead of absolutely defining the width and height of your elements, you can set minimum and maximum widths and heights. This allows you to resize elements based on the browser or their parent elements. The idea of creating flexible content that adjusts to the user’s browser/device is at the core of what is referred to as responsive design. .size-me { min-width: 200px; max-width: 100px; }"
  • 29.
  • 30. Centered, Fixed-width Page ! body { width: 960px; margin: 0 auto; }
  • 31.
  • 32. Float and set 300px width on article element ! ! !
  • 33. Defining dimension: min-width and max-width ! ! !
  • 35. Defining dimension: change display property of anchors ! ! !
  • 36. Clear the footer ! ! ! ! !
  • 37. Clear the footer When you float an element, their containing element no longer recognizes their width or height (the are out of the “flow”). This becomes and issue if the floated content is taller than the containing element. There are several ways to fix this; the easiest way is to set the overflow property on the containing div to “auto”. .containing-div { overflow: auto }" ! !
  • 38. Make it responsive ! @media only screen and (max-width: 767px) { body { width: 100%; } article { width: auto; margin: 20px; } h1 { padding: 0 20px; } }
  • 40. There are four basic declarations you can use to position your boxes: float: left (or right) position: relative position: fixed position: absolute
  • 41. The normal flow & position:static Static positioning is the default – this is referred to as the “normal flow”. block boxes are positioned on a page one after the other (in the order they're written in the HTML). They start in the upper left of the containing box and stack from top to bottom. The distance between each box is defined by the margins with top and bottom margins collapsing into one another. ! ! ! <div id=”header”></div> <div id=”content”></div> <ul id=”sidebar-nav”></ul>
  • 42.
  • 43.
  • 44. float A floated element takes the element out of the normal flow and moves it to the far right or left of the containing element. Existing content will then flow around it. Floated elements should always have at least a width property. .photo { float: left; max-width: 150px; }" ! !
  • 45. Class Exercise ! 4 Float
  • 46.
  • 47. Class Exercise ! 5 Two-Column layout
  • 48.
  • 49.
  • 50. Class Exercise ! 6 Fixed/Flexible Hybrid Layout
  • 51. Positioning Properties There are four values that you can give to the position property: ! static Elements renders in order, as they appear in the document flow. This is default. relative The element is positioned relative to its static position, so “left:20” adds 20 pixels to the element’s LEFT position. absolute The element is positioned relative to its first positioned (not static) ancestor element (usually, the first parent with position:relative). fixed The element is positioned relative to the browser window.
  • 52. Class Exercise ! 7 Positioning
  • 53. boxes exercise .box { "" width: 300px; "" height: 300px; "" border: 1px solid #333; "" margin: 10px; "" display: inline-block; }" " .relative { "" position: relative; "" top: 50px; "" left: -50px; }" .fixed { "" position: fixed; "" bottom: 0; "" left: 0; }" ! !
  • 54. boxes exercise .box.absolute { "" position: relative; }" .box.absolute p { "" position: absolute; "" top: 0; "" right: 0; "" background: #444; "" padding: 10px; "" margin: 0; "" color: #fff; }" ! ! !
  • 55. relative A relative positioned element moves the element out of it’s position in the normal flow, and allows you to move it “relative” to that location. The space taken by the original location is retained in the flow. .date { position: relative; top: 40px; left: -105px; }" ! !
  • 56. relative exercise ! ! .date { ! position: relative; top: 40px; left: -105px; }" ! !
  • 57. fixed A fixed element is taken complete out of the document flow, and is positioned relative to the browser window. .create-change { position: fixed; bottom: 40px; right: 0; }" ! !
  • 58. fixed exercise ! ! .create-change { ! position: fixed; bottom: 40px; right: 0; }" ! !
  • 59. absolute The element is positioned relative to its first positioned (not static) ancestor element. The element and its spacing are completely taken out of the flow. In the example below, the “.post” parent element is given a position value of relative, which lets us set it’s child element “.icon” within it. .post { position: relative; }" .icon { position: absolute; left: -60px; right: 0; }" ! !
  • 60. absolute exercise ! ! .post { ! position: relative; }" .icon { position: absolute; left: -60px; right: 0; }" ! !