This is a discussion on "When is it ok to use Absolute Positioning ??" within the Web Page Design section. This forum, and the thread "When is it ok to use Absolute Positioning ?? are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
When is it ok to use Absolute Positioning ??
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
When is it ok to use Absolute Positioning ??
Hi all ,
I am currently designing a site in xhtml/css within Dreameaver and was wondering if in my scenario i SHOULD use Absolute Positioned DIVS ...... The site was designed in Photoshop and sliced into 3 parts (header/body/footer), these 3 slices i want to line up perfectly within dweaver , all inside a container div. I would assume on this occasion i would use Absolute ??? but not entirely sure!! Would i use relative Divs and floats...if so how the hell do you do that !!! (lol) Also .. slightly off subject, should i use em or px for my font sizes ... i tried ems , but even at 1em size the text was rather large on the screen ?!?! many thanks !!! |
|
|
|
||||
|
Re: When is it ok to use Absolute Positioning ??
This wouldn't be a case for using absolute positioning. It probably wouldn't be a case for relative position or even floats either
If you have three parts to your site inside of a wrapper, all you need to do is give the wrapper a width and place three divs.. Head, body, foot inside the wrapper. Make sure these divs have no margins and no white-space between them and they will line up. take this example (using inline styles but would be better to place them in a style sheet)
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: When is it ok to use Absolute Positioning ??
thanks for the advice Rakuli , i had absolute positioned divs for those 3 elements !?!? a lot of lines of code in my Stylesheet !!! that worked great .... the only thing now is that a Div containing text that i had positioned over my body Div has now jumped to the very bottom of the screen ?!?
Oh and my navigation div which was positioned like this : #navigation { position:relative; left:439px; top:0px; width:532px; height:62px; z-index:2; } has now done the same thing (damn!!!) |
|
||||
|
Re: When is it ok to use Absolute Positioning ??
Okay, if you need to have a div positioned over an element. That is, out of the flow and not affected by other objects, this is a reason to use absolute positioning.
If you have these divs inside of the body element, make the body position: relative. Then add position: absolute to the elements you want to be placed over the top of the element. If you are positioning these elements on either side of the body though, it may be better to float the elements to either side. This will mean the content of the body divs will wrap around them.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: When is it ok to use Absolute Positioning ??
what do you mean by 'either side of the body' , is this referring to the <body> tags ???
|
|
||||
|
Re: When is it ok to use Absolute Positioning ??
The body div -- ie, the second div inside the wrapper from my example above.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: When is it ok to use Absolute Positioning ??
would i then code as such :
<div id="body"><div id="text"> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec rhoncus neque sit amet odio. Duis fringilla arcu placerat nunc. Cras mattis euismod ante. Aliquam erat volutpat. Aenean pulvinar turpis mattis ipsum. Proin vestibulum semper risus. Maecenas diam. Donec nonummy neque. Etiam suscipit nunc eu tortor. Vivamus volutpat, risus non consectetuer molestie, justo velit consequat mi, sit amet ullamcorper nunc elit aliquet orci. Proin purus turpis, tincidunt ut, lacinia sit amet, pharetra at, lorem. Morbi mattis metus id ipsum iaculis porta. Maecenas ut ipsum sed est commodo placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In posuere lorem. Duis aliquam, est sed euismod scelerisque, tortor felis lobortis arcu, a aliquam nisl urna quis risus. Quisque ac elit vitae turpis porttitor fermentum. Nullam dignissim, massa sed pretium vestibulum, leo elit vulputate urna, in luctus nunc orci in marcus. </p> </div></div> can u actually put 2 <div id> within each other ?? is this good practice?? thanks again rakuli Last edited by slimboyfatz32; Feb 5th, 2008 at 11:34. |
|
||||
|
Re: When is it ok to use Absolute Positioning ??
You can put two divs within each other. They are block - level elements so this is not problem. If they are unique on the page you can give them both Id's as well.
Provided you're closing all the required elements then it's good practice.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: When is it ok to use Absolute Positioning ??
so the code that i posted above would be good practice ???
can i show you this code , just to see if i'm getting it correctly .............. Quote:
Quote:
|
|
||||
|
Re: When is it ok to use Absolute Positioning ??
This would be incorrect because you are using absolute positioning when there is no reason to. You are using the position to place text inside of the id="main" div. You should just place the text inside this div.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: When is it ok to use Absolute Positioning ??
thanks again for all the advice rakuli.......how would i now stop the text from stretching from one side of the <main> div to the other , i really only want it going about halfway across the screen.
Would i also use the same practice for a navigation menu which appears over the top of my header? Or would this need to be contained within a seperate Div ie: <div id="navigation"> <a class="homeButton" href="index_test.html" title="Home"></a> <a class="contactButton" href="contact.html" title="Contact Us"></a> </div> #navigation { position:absolute; left:439px; top:0px; width:532px; height:62px; z-index:2; many thanks again for your great advice!!! |
|
||||
|
Re: When is it ok to use Absolute Positioning ??
To stop the text strecthing all the way across the screen you can use
As for the navigation in the top panel, yes you want to put it inside the #head div. If you want it to be along the bottom of the top div, give the #head a position: relative and use the following on a div inside the head with the id of #navigation.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: When is it ok to use Absolute Positioning ??
i am looking at positioning the 'navigation' to the top right of the header. Would this be the correct CSS ......
Quote:
is this the correct markup too ..... Quote:
|
|
||||
|
Re: When is it ok to use Absolute Positioning ??
If you're looking at position at the top, then don't use any positioning at all
Just use
The markup is fine... You can check to be doubly certain at http://validator.w3.org . It has a service that allows you to input code directly.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: When is it ok to use Absolute Positioning ??
that did the trick .... so simple but so right !!!!
do you reckon my 'stylesheet' looks in good shape now ? or more refining needed (ie corrections , shorthand etc..) Quote:
|
|
||||
|
Re: When is it ok to use Absolute Positioning ??
It all looks pretty good
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: When is it ok to use Absolute Positioning ??
thanks for all the advice !!!
|
|
||||
|
Re: When is it ok to use Absolute Positioning ??
Just a side note.. Stay away from Absolute positioning unless its 100% necessary. Fluid layouts are much better.
Last Blog Entry: Happy Holidays - A Non Offensive way to say Merry Christmas? WRONG! (Dec 11th, 2007)
|
|
|||
|
Re: When is it ok to use Absolute Positioning ??
Thanks for the advice , do you think my CSS code above looks fine ?? should i remove 'Absolute Positioning' from within my buttons ??
thanks |
|
||||
|
Re: When is it ok to use Absolute Positioning ??
send me a link of the page working live. That way I can see the graphics and things with no problems. I've done extremely complicated layouts and never used position or z-index. So I know that these can be taken out. Also, I've never ever seen a need to hack for IE. There's always a way to write 1 css that can work on both. Yes IE has bugs, but heck, there's ways around them.
Last Blog Entry: Happy Holidays - A Non Offensive way to say Merry Christmas? WRONG! (Dec 11th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| positioning - relative or absolute? | Web Page Design | 13 | Nov 8th, 2007 16:00 | |
| absolute positioning | micker | Flash & Multimedia Forum | 1 | May 21st, 2007 19:17 |
| Trouble with absolute positioning | minerguy | Web Page Design | 4 | May 26th, 2006 04:35 |
| Rollovers and absolute positioning | echo | Web Page Design | 5 | May 2nd, 2006 10:51 |
| absolute bottom positioning in all browsers | stephenleefarmer | Web Page Design | 5 | Dec 6th, 2005 23:19 |