I'm reading around on the web, trying to understand the "best practices" of creating css files, and I am now getting the impression that absolute positioning is not the "recommended" way of going about it. If this is the case, why?
CSS:Is only using absolute positioning bad, and if so, why?
Hi sohrabx,
Absolute positioning can become a useability issue when users have small browser windows.
Absolutely positioned elements are taken out of the normal document flow, so other items may overlay or clash with them.
It is better to avoid when possible, or at least use with caution.
Hope that helps
I see, but, what if... :)
What you stated makes a lot of sense, I now understand, thank you very much for the reply
just one other addition to my question, it was stated "Absolutely positioned elements are taken out of the normal document flow, so other items may overlay or clash with them.
"
What if you absolute positioned all the elements on your page and made sure that they didn't overlay on each other?
-Sohrab
CSS:Is only using absolute positioning bad, and if so, why?
I can only see pure absolute positioning working in a few limited instances. The main issue that I see is that anything absolutely positioned is completely dependent on the window size and resolution. Alas, window size and resolution are user-specific and incredibly dynamic in nature, creating an obvious clash.
I mentioned a few limited instances- for example, it would work if you're using small to medium popup windows and can control the window size and restrict window-resizing.
For a more visual example, if you care to track down any links of pure absolutely positioned webpages, I'd be happy to run them through BrowserCam and see how well (if at all) it degrades.
CSS:Is only using absolute positioning bad, and if so, why?
KnightWolf:
I have used absolute positioning on a couple things:
http://mx.coldstorageonline.com/layout2/
http://mx.coldstorageonline.com/hrd/default.htm
The reason I used absolute positioning for these was because then I can have the nav elements at the bottom of the XHTML, which means that people that view it with really old browsers or with stylesheets off get the content first, instead of having to scroll past a ton of navigation items...
That's the main benefit I can see behind using CSS-P...
CSS:Is only using absolute positioning bad, and if so, why?
what about using absolute positioning, but using % for div widths so that they fit even in a smaller browser window? i'm using mostly absolute positioning for my site, so tell me if i should be doing something else.
CSS:Is only using absolute positioning bad, and if so, why?
Hi,
Most sites use a combination of positioning techniques but they do rely on the objective to be acheived.
If you want overlapping elements then you will need absolute (or relative) positioning. If your whole document flows one element after the other then static (the default) is ok.
Pixel perfect layout can be achieved in CSS with a mixture of techniques.
Don't forget you can move static elements by adjusting their margins to position them more precisely.
You can also absolutely place elements in relation to its parent element instead of the viewport. This is achieved by giving the parent a value for the property position other than static. With this technique you could absolutely place an element inside a container that has a fluid width/height and the absolute element will adjust with its parent.
Most of the elements on a page will usually be in the normal flow with some elements absolutely positioned.
However its all down to choice though as mentioned in the posts above the web page is a dynamic medium and it best not to try and control every aspect of your page. With a suitable browser the visitor can change everything about your page from the size of the text and layout to the stylesheets they are going to use. You never know what your visitor is going to view your site on (e.g. hand-held or massive monitor).
It all boils down to making the right choice for you and your audience.
Paul