class 3 & 4: layouts
TRANSCRIPT
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 1/33
Class 3 & 4
layouts
Web Design, gRAPH-3271-01
Instructor: Erika Tarte
Rhode Island School o Design
Wintersession 2011
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 2/33
one final html
ingredient
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 3/33
HTML element using the tags <div>& </div>
Completely arbitrary (like spans)
No deault styles or behaviors
div
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 4/33
<div> same HTML rules apply. Divs have an oPening tAg
<h1>Headline<h1>
<p>Paragraph of text</p>
</div> and closing tAg
div
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 5/33
Divs organize HTML
They are used to create structure on a webpage
They group elements
They can dene a particular section or zone o a webpage (header, sidebar, article, etc.)
divs are containers
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 6/33
<div>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
<div>
<h1>Headline 2<h1>
<p>Paragraph of text</p>
</div>
divs are containers
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 7/33
<div class=”article”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
<div class=”article”>
<h1>Headline 2<h1>
<p>Paragraph of text</p>
</div>
divs are containers
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 8/33
<div class=”articles”>
<div class=”article”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
<div class=”article”>
<h1>Headline 2<h1>
<p>Paragraph of text</p>
</div>
</div>
divs are containers
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 9/33
<div class=”header”>
...
</div>
<div class=”articles”>
<div class=”article”>
...
</div>
<div class=”article”>
...
</div>
</div>
divs are containers
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 10/33
Divs organize/structure/group HTML
But because they are arbitrary and have no inherent styles or behaviors...
They are pretty much meaningless without CSS
divs love css
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 11/33
Divs allow you to assign a class to a particular section o your HTML
divs & classes
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 12/33
<div class=”article”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
divs love css
h1 {
color:#000000;
}
h1 .article {
color:#ff0000;
}
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 13/33
position
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 14/33
Divs allow you to assign a position sections o your HTML
divs & positioning
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 15/33
Divs are used to break out o HTML’s linear structure
Can be positioned anywhere on the page, relative to the container they are in
4 types o positioning using the position CSS property:
position: static; this is the DefAult, what we’ve been seeing w/ all the HTML elements
position: relative; defines an objects position RelAtive to its DefAult Position
position: absolute; defines a position RelAtive to the toP left coRneR of its contAineR
position: xed; defines a position that is RelAtive to tHe bRoWseR WinDoW
divs & positioning
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 16/33
Once a div has a type o position, you can use these properties to speciy their placement
top: value; defines a position RelAtive to the toP of its contAineR
right: value; defines an objects position RelAtive to the RigHt of its contAineR
bottom: value; defines a position RelAtive to the bottom of its contAineR
left: value; define a position that is RelAtive to the left of its contAineR
divs & oset positioning
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 17/33
<div class=”articles”>
<div class=”article”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
</div>
position: static
div.articles {
position: static;
}
div.article {
position: static;
}
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 18/33
<div class=”articles”>
<div class=”article”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
</div>
position: relative
div.articles {
position: relative;
}
div.article {
position: relative;
top: 50px;
left: 100px;
}
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 19/33
<div class=”articles”>
<div class=”article”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
</div>
position: absolute
div.articles {
position: absolute;
}
div.article {
position: absolute;
bottom: 50px;
right: 100px;
}
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 20/33
<div class=”articles”>
<div class=”article”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
</div>
position: xed
div.articles {
position: xed;
}
div.article {
position: xed;
bottom: 50px;
right: 100px;
}
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 21/33
Use sparingly!
Easy or you and the browser to get conused
Oten used as a quick x or hack when a more logical approach could have been used
Browsers are notorious or rendering positions and oset positions dierently
problems with positioning
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 22/33
float
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 23/33
Floats are another way o creating layouts
Floats make html objects fow let > right, top > bottom just like text would
Layouts depend on div position in HTML, direction they foat, and whether they clear
foats: a more logical approach!
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 24/33
Floats use the CSS property oat and the values left, right andnone
They also use the CSS property clear and the values left, right andnone
Floated elements will move to the ar let/right within their container
They will stop when they hit another element
I their clear is set to that direction, they will jump down to the next line
I they don’t have a clear, they will stay smashed up against that other element
foats
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 25/33
<div class=”article1”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
<div class=”article2”>
<h1>Headline 1<h1>
<p>Paragraph of text</p></div>
foat:let
div.article1 {
oat:left;
width:200px; height:400px;
background-color:#ff00ff;
}
div.article2 {
oat:left;width:200px; height:400px;
background-color:#0000ff;
}
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 26/33
foat:let
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 27/33
<div class=”article1”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
<div class=”article2”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
foat:let; clear:let;
div.article1 {
oat:left;
width:200px; height:400px;
background-color:#ff00ff;
}
div.article2 {
oat:left;
clear:left;
width:200px; height:400px;
background-color:#0000ff;
}
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 28/33
foat:let; clear:let;
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 29/33
<div class=”articles”>
<div class=”article1”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
<div class=”article2”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
</div>
foat:let; & foat:right;
div.article1 {
oat:left;
width:200px; height:400px;
background-color:#ff00ff;
}
div.article2 {
oat:right;
width:200px; height:400px;
background-color:#0000ff;
}
div.articles {
oat:left;
width:100%;
background-color:#00ff00;
}
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 30/33
foat:let; & foat:right;
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 31/33
<div class=”article1”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
<div class=”articles”>
<div class=”article2”>
<h1>Headline 1<h1>
<p>Paragraph of text</p>
</div>
</div>
foat:let; & foat:right;
div.article1 {
oat:left;
width:200px; height:400px;
background-color:#ff00ff;
}
div.article2 {
oat:right;
width:200px; height:400px;
background-color:#0000ff;
}
div.articles {
oat:right;
width:400px;
background-color:#00ff00;
}
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 32/33
foat:let; & foat:right
8/8/2019 Class 3 & 4: Layouts
http://slidepdf.com/reader/full/class-3-4-layouts 33/33
exercises 1–4