CSS-P (Cascading Style Sheet - Position)
by K. Yue, copyright 2000
October 18, 2000
Introduction
Example:
<DIV ID="mydiv"
STYLE="position: absolute; left: 100px; top: 50px; width: 80px; height:
40px; visibility: visible;">
HTML goes here
</DIV>
which is the same as
<DIV ID="mydiv" STYLE="position:absolute; left:100;
top:50; width:80;">
HTML goes here
</DIV>
Absolute Positioning
Relative Positioning
CSSP Properties
Property | Value |
position | absolute | relative | static |
left | length | percentage | auto |
top | length | percentage | auto |
width | length | percentage | auto |
height | length | percentage | auto |
clip | shape | auto |
overflow | none | clip | scroll |
z-index | auto | integer |
visibility | inherit | visible | hidden |
Examples:
noposition.html: not using any positioning.
<html>
<head>
<title>No Positioning</title>
<style TYPE="text/css">
#outer {color: red }
#inner { color: blue }
</style>
</head>
<body><p>Beginning
<span id=outer>
Outer content starts.
<span id=inner>Inner content.
</span>
Outer content ends.
</span>
End body.
</p></body>
</html>
absposition.html: using absolute positioning
<html>
<head>
<title>Absolute Positioning</title>
<style TYPE="text/css">
#outer { position: absolute;
top: 200px;
left: 200px;
color: red }
#inner { color: blue }
</style>
</head>
<body><p>Beginning
<span id=outer>
Outer content starts.
<span id=inner>Inner content.
</span>
Outer content ends.
</span>
End body.
</p></body>
</html>
relposition.html: using relative positioning.
<html>
<head>
<title>Relative Positioning</title>
<style TYPE="text/css">
#outer { position: relative;
top: 200px;
left: 200px;
color: red }
#inner { color: blue }
</style>
</head>
<body><p>Beginning
<span id=outer>
Outer content starts.
<span id=inner>Inner content.
</span>
Outer content ends.
</span>
End body.
</p></body>
</html>
zindex.html: a demo of using z-index.
<HTML>
<HEAD>
<TITLE>Z-Index Example</TITLE>
<STYLE TYPE="text/css">
#first { position:absolute; top: 100px; left: 100px; z-index: 1;
color: yellow }
#second { position:absolute; top: 103px; left: 103px; z-index: 2;
color: lime }
#third { position:absolute; top: 106px; left: 106px; z-index: 3;
color: fuchsia }
#fourth { position:absolute; top: 109px; left: 109px; z-index: 4;
color: red }
</STYLE>
</HEAD>
<BODY>
<H1>Demo: z-index</H1>
<P ID=first>Software Tools ...</P>
<P ID=second>Software Tools ...</P>
<P ID=third>Software Tools ...</P>
<P ID=fourth>Software Tools ...</P>
</BODY>
</HTML>