Lecture 5
Lecture 5
Regular text
Box Model
Margin
Border
Padding
Content
Box Model
Think of it like an egg:
CSS
.float {float:right;}
HTML Absolute
<div>
This is the normal flow of a
<p> This is the
document; from top to bottom, left
normal… <span
to right. When you add the
class=“abs”> This
absolutely positioned This
text, text
it is
text is absolutely absolutely
moves to the coordinates you set
positioned.</span>… positioned.
based on the top left corner of the
top to bottom… </p>
containing element, in this case
</div> the <div>. Normal text flows over
the absolutely positioned text.
CSS There is no gap where the text is
.abs {position: absolute; taken from.
top: 40px;
left: 80;}
This text is relatively
positioned.
HTML Relative
<div> This is the normal flow of a
document; This text is relatively
<p> This is the
positioned from top to bottom, left
normal… <span
to right. When you add the
class=“rel”> This text
relatively positioned text, it moves
is relatively positioned.
to the coordinates you set based
</span> … from top to
on the top left corner of the
bottom…</p>
containing element, in this case
</div> the <div>. Normal text flows as
normal, but a gap is left where the
CSS relative text used to be, and the
.rel {position: relative; text overlaps with the newly
top: -50px; positioned relative text if they are
left: -150px} in the same area.
<html>
<head>
<title>My Resume</title>
<link href=“home.css" rel="stylesheet"
type="text/css">
</head>
<body>
<div id="container">
Content goes here
</div>
</body>
</html> HTML
#container
#banner
#nav #content
#footer
<body>
<div id="container">
<div id="banner"><img src="pic.jpg" /></div>
<div id="nav">
<span><a href="home.htm">home</a></span>
<span><a href="contact.htm">contact</a></span>
</div>
<div id=“content">
<h1>My Resume</h1> HTML
<p>Resume text</p>
</div>
<div id=“footer”>Copyright info here</div>
</div>
</body>
body {
font-size: 1em; }
#container {
width: 920px; }
#banner {
width: 920px; height: 120px; }
#nav {
float: left; width: 200px; } CSS
#content {
width: 720px; }
#footer {
font-size: .8em; }