positioning in css

I

Ike

Can anyone show me an example of simple positioning using a css? Something
along the lines of positioning something at 0,0 (top,left) ?

Thanks, Ike
 
G

GD

Ike said:
Can anyone show me an example of simple positioning using a css?

If you mean absolute positioning:

#foo {
position:absolute;
z-index:2;
top:0;
left:0;
width:100%;
background:#000;
color:#fff;
}

Then in the HTML:

<div id="foo">This is absolute positioning</div>


Relative positioning works differently. It doesn't remove the element
from the flow of the page, it just offsets the element from its original
position after it's been drawn:

p em {
position:relative;
top:-1em;
left:1em;
background:#f00;
color:#ff0;
}


Then in the HTML:

<p>This is <em>relative</em> positioning</p>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top