Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-11-2013, 08:27 AM   PM User | #1
giaibongda
New to the CF scene

 
Join Date: Jan 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
giaibongda is an unknown quantity at this point
Position in CSS

- Different Position absolute and relative in css? and when i use it? Help me! Thanks.
giaibongda is offline   Reply With Quote
Old 01-11-2013, 01:14 PM   PM User | #2
L0adOpt1c
New Coder

 
L0adOpt1c's Avatar
 
Join Date: Jan 2013
Location: <bed />
Posts: 95
Thanks: 0
Thanked 7 Times in 7 Posts
L0adOpt1c is an unknown quantity at this point
Absolute positioning places something on the page at a fixed position, via the 'top' and 'left' values. Like this:

Code:
#objectcalled {
position:absolute;
top: 760px;
left: 40px;
}
Relative positioning places something on the page relative to other elements on the page. Like this:

Code:
#objectcalled {
position:relative;
top: 760px;
left: 40px;
}
Hope this helped.
L0adOpt1c is offline   Reply With Quote
Old 01-11-2013, 03:57 PM   PM User | #3
TFlan
New Coder

 
Join Date: Dec 2012
Location: USA
Posts: 82
Thanks: 3
Thanked 17 Times in 17 Posts
TFlan is an unknown quantity at this point
Above poster has it semi-right..

There are 4 options for the position attribute:
  • Fixed
  • Static
  • Absolute
  • Relative

Fixed positioning is a lot like absolute positioning. The position of the element is calculated in the same way as the absolute model - from the sides of the view port. But fixed elements are then fixed in that location, like a watermark. Everything else on the page will then scroll past that element.

Static is the default position for any element on a Web page. If you don't define the position, it will be static and will display on the screen based on where it is in the HTML document and how it would display inside the normal flow of the document.

Absolute tells the browser that whatever is going to be positioned should be removed from the normal flow of the document and will be placed in an exact location on the page. It won't affect how the elements before it or after it in the HTML are positioned.

Relative positioning is basing the position of the element upon the browser view port, it starts from where the element would be if it were still in the normal flow. (Relative to it's starting, normal position.)
TFlan is offline   Reply With Quote
Old 01-11-2013, 06:13 PM   PM User | #4
j4v3d
New Coder

 
Join Date: Mar 2009
Location: UK
Posts: 34
Thanks: 6
Thanked 0 Times in 0 Posts
j4v3d is an unknown quantity at this point
You should try avoid using position absolute. I dont quite like it. But if you have a div that's in the bottom right hand corner and have a few divs within that you could position the outer div relatively and then anything inside you can place position absolute to that out div.

Best way to know when to use it is by playing around with the HTML/CSS and you'll get the gist of it.
__________________
MJCoder
Twitter
j4v3d is offline   Reply With Quote
Reply

Bookmarks

Tags
position css

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:25 AM.


Advertisement
Log in to turn off these ads.