positioning - relative or absolute?

This is a discussion on "positioning - relative or absolute?" within the Web Page Design section. This forum, and the thread "positioning - relative or absolute? are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 29th, 2007, 22:26
Junior Member
Join Date: Oct 2007
Location: hello
Age: 28
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
positioning - relative or absolute?

hi all, im relatively new to web design, only got in to css last week and still learning a lot.

i made my first proper functional site, using fully w3 compliant html and css yesterday, but have been told that my method for positioning divs etc i bad.

the way i do it at the moment, the only way i know how, is using absolute positioning. so my stylesheet is sort of as follows:

Code: Select all
div.logo
{
    border-style: solid;
    border-width: 1px;
    border-color: #3D3D3D;
    position: absolute;
    background: url('../images/topbg.jpg');
    background-repeat: repeat-x;
    text-align: left;
    width: 65%;
    top: 5px;
    left: 17.5%;
    right: 17.5%;
    height: auto;
}

div.topbar
{
    border-style: solid;
    border-width: 1px;
    border-color: #3D3D3D;
    background: url('../images/topbarbg.jpg');
    background-repeat: repeat-x;
    position: absolute;
    width: 65%;
    left: 17.5%;
    right: 17.5%;
    top: 103px;
    height: 24px;
    text-align: right;

}

div.content
{
    background-color: #FFFFFF;
    border-style: solid;
    border-width: 1px;
    border-color: #3D3D3D;
    border-top: none;
    position: absolute;
    top: 129px;
    bottom: 31px;
    width: 65%;
    left: 17.5%;
    right: 17.5%;
    text-align: center;
}

div.content_box
{
    position: absolute;
    top: 1%;
    left: 20%;
    right: 1%;
    bottom: 1%;
    text-align: center;
    overflow: auto;
}
so im setting the absolute positions of everything. i have been told this i bad, and that i should use relative positions, but i just dont understand how. help would be appreciated, thx!
Reply With Quote

  #2 (permalink)  
Old Oct 30th, 2007, 08:36
marSoul's Avatar
Moderator
Join Date: Sep 2007
Location: Tehran - Iran
Age: 28
Posts: 411
Blog Entries: 2
Thanks: 3
Thanked 4 Times in 4 Posts
Send a message via MSN to marSoul Send a message via Yahoo to marSoul
Re: positioning - relative or absolute?

You can see this link :
http://www.w3schools.com/css/pr_class_position.asp
it has examples of how they work
__________________
Designing For Communicating
Website : http://www.datisdesign.com
Weblog : http://blog.datisdesign.com

Last Blog Entry: Throughout IRAN (Dec 10th, 2007)
Reply With Quote
  #3 (permalink)  
Old Oct 30th, 2007, 09:43
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning - relative or absolute?

You should not use positioning at all yet. Learn how to use floats first. Most page layouts can easily be achieved using floats.

Absolute and relative positioning are highly specialised tools. Don't use them indiscriminately, or you'll create a horrible mess!
Reply With Quote
  #4 (permalink)  
Old Oct 30th, 2007, 10:28
Junior Member
Join Date: Oct 2007
Location: hello
Age: 28
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning - relative or absolute?

Quote:
Originally Posted by marSoul View Post
You can see this link :
http://www.w3schools.com/css/pr_class_position.asp
it has examples of how they work

sorry, but i dont understand any of that lol
Reply With Quote
  #5 (permalink)  
Old Oct 30th, 2007, 10:34
marSoul's Avatar
Moderator
Join Date: Sep 2007
Location: Tehran - Iran
Age: 28
Posts: 411
Blog Entries: 2
Thanks: 3
Thanked 4 Times in 4 Posts
Send a message via MSN to marSoul Send a message via Yahoo to marSoul
Re: positioning - relative or absolute?

which part dont u understand ?
__________________
Designing For Communicating
Website : http://www.datisdesign.com
Weblog : http://blog.datisdesign.com

Last Blog Entry: Throughout IRAN (Dec 10th, 2007)
Reply With Quote
  #6 (permalink)  
Old Oct 30th, 2007, 11:58
SuperMember

SuperMember
Join Date: Sep 2006
Location: Pink House
Posts: 3,946
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning - relative or absolute?

I never understand W3Schools either...
It's like reading an encyclopedia.

Try this tutorial. It will show you how to create a simple 2 column layout without using any positions. Just floats. Once you learn this... you will be so happy!

Positions should not be used for most elements because they will cause headaches. On occasion you will need them but rarely.
Reply With Quote
  #7 (permalink)  
Old Oct 30th, 2007, 15:41
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning - relative or absolute?

Yeah ... I never use position: absolute or position: relative .... only float: left or float: right

Less headaches
Reply With Quote
  #8 (permalink)  
Old Oct 30th, 2007, 15:48
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning - relative or absolute?

Quote:
Originally Posted by karinne View Post
Yeah ... I never use position: absolute or position: relative .... only float: left or float: right

Less headaches
There are, however, some nifty applications of positioning. For example, by applying absolute positioning to an image inside a relatively positioned parent, I can create a decorative image that breaks out of its parent's containing block, yet whose position will remain fixed relative to the parent (not the viewport).

This technique is superb for decorating pages in an elastic layout. If you scale the layout, the image will remain anchored in whatever way you desire.

Last edited by MikeHopley; Oct 30th, 2007 at 15:50.
Reply With Quote
  #9 (permalink)  
Old Oct 30th, 2007, 15:50
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning - relative or absolute?

I don't deny that they have their uses but for someone who is just learning CSS, it's best, like you said, to stay away from them
Reply With Quote
  #10 (permalink)  
Old Oct 30th, 2007, 16:05
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: positioning - relative or absolute?

I only use absolute for banners in the top left/right.
It's quite useful for that
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #11 (permalink)  
Old Oct 30th, 2007, 16:08
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,649
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: positioning - relative or absolute?

Hi Google,

If you want to get a better understanding (while you are doing/looking at Linda's tutorial) have a look at this site before hand: http://css.maxdesign.com.au/floatutorial/.

I found it very interesting and helpful when i started out.
Reply With Quote
  #12 (permalink)  
Old Oct 31st, 2007, 04:16
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: positioning - relative or absolute?

Position absolute used by spamers to create their pop up irritating advertisement window!
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #13 (permalink)  
Old Nov 8th, 2007, 15:39
Junior Member
Join Date: Nov 2007
Location: Norwich, UK
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning - relative or absolute?

There's many valid uses for positioning especially when your source code is ordered in a different way to the design. I'd recommend reading Andy Clarke's Transcending CSS for examples - an excellent book anyway.

James.
Reply With Quote
  #14 (permalink)  
Old Nov 8th, 2007, 16:00
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: positioning - relative or absolute?

I definitely recommend Andy's book ... I read it and I learned quite a few things.

But ... for simple design, floats are the best to use.
Reply With Quote
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Absolute Div, wrapped in Relative Div (IE6 - AARRRGGHH) tenderfoot Web Page Design 3 Feb 7th, 2008 18:43
When is it ok to use Absolute Positioning ?? slimboyfatz32 Web Page Design 31 Feb 6th, 2008 17:25
absolute positioning micker Flash & Multimedia Forum 1 May 21st, 2007 19:17
CSS Challenge... absolute AND relative positionning Trollivier Web Page Design 5 Feb 9th, 2007 16:41
loadMovie function (and absolute/relative URL's) DocBoy52 Flash & Multimedia Forum 1 Aug 26th, 2006 05:16


All times are GMT. The time now is 07:03.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43