Web Design & Development

[ Web Design & Development Topics ]

CSS Positioning

Positioning properties let you specify the top, bottom, left and right positions of elements. With this you can specify the shape of an element or overlap elements. Positioning properties include:

Example:

h1
{
position:absolute;
left:100px;
top:150px;
}

Lets try it: http://www.w3schools.com/css/css_positioning.asp

Samples:

Note:

On the overlapping items you can also specify other attributes like background color. It should be noted that background-color:transparent may prove useful to you sometimes.

Consider this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#overlay {
position:absolute;
width:200px;
border: thick #00703c dotted;
z-index:1;
left: 132px;
top: 40px;
color:red;
background-color:transparent;
}
#overlay2 {
position:absolute;
width:200px;
border: medium brown dashed;
z-index:2;
color: #CC0000;
left: 232px;
top: 30px;
background-color:yellow;
}
-->
</style>
</head>

<body>
I am a bunch of text I am a bunch of text I am a bunch of text I am a bunch of text
I am a bunch of text I am a bunch of text I am a bunch of text I am a bunch of text
I am a bunch of text I am a bunch of text I am a bunch of text I am a bunch of text
I am a bunch of text I am a bunch of text I am a bunch of text I am a bunch of text
I am a bunch of text I am a bunch of text I am a bunch of text I am a bunch of text

<div id="overlay">I am red text I am red text I am red text I am red text I am red text I am red text I am red text I am red text I am red textI am red text I am red text I am red text I am red text I am red text I am red text</div>

<div id="overlay2">I am red text I am red text I am red text I am red text I am red text I am red text I am red text I am red text I am red textI am red text I am red text I am red text I am red text I am red text I am red text</div>
</body>

Try it and see if it does what you expected.