View Full Version : Position:absolute not recommendable?
Jerome
03-16-2003, 11:59 AM
Hi,
I read some opinions about DIV positioning:absolute which people doesn't seem to like.
Q1.
Why?
Thanks,
Jerome
scroots
03-16-2003, 12:09 PM
it throws stuff out of proportiion. If you design everything position:absolute for 800X600 fine but what happens at higher resolutions its a mess. Also if the browser window is resized etc.
scroots
Jerome
03-16-2003, 12:22 PM
You are right, however I forgot to tell that I only use % for positioning.
Does this still make - absolute - not affordable
Jerome
scroots
03-16-2003, 12:32 PM
if you use the percentage method rather than pixels you should be ok. but i'm not an expert at this.
scroots
brothercake
03-16-2003, 02:21 PM
Yup % as an absolute unit is perfectly fine; very useful in fact, for layouts like yours where you want precise control, but flexible to window size :)
There's another unit - em - which is conversely useful: it's an absolute unit (not relative to window size), but it scales; check out my hybrid navbar (http://www.brothercake.com/scripts/navmeister/page.php) to see it in action - the sizes and positions are the same at all window sizes, but the whole things scales when you change the view font size
Jerome
03-16-2003, 03:07 PM
Exactly, it takes some time to figure-out the formats which You want to handle, but after the results are resolution-independent.
Thanks,
Jerome
Skyzyx
03-17-2003, 07:13 AM
Another thing that many people seem not to understand at the beginning is that you can have an absolutely positioned DIV nested inside a relative DIV, which will allow much more control over your design.
...
<style type="text/css">
.outer {
position:relative;
top:0px;
left:0px;
background-color:#DDDDDD;
}
.inner {
position:absolute;
top:10px;
left:100px;
width:100px;
background-color:#999999;
}
</style>
</head>
<body>
This is some text...<br /><br /><br /><br />
<div class="outer">
<div class="inner">
What? Me worry?
</div>
</div>
</body>
...
See...?
Absolutely. :thumbsup:
The problem occurs when every single item is positioned absolutely relative the browser window. Using it for one or two layout boxes can be as flexible as you want not to speak of using it in a limited area as Skyzyx describes.
I think it's DW that fancies those rigid 'position everything' layouts.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.