Absolutely Positive
It’s becoming increasingly clear (no pun intended) that I need to have some sort of dedicated portion of this website for these little scripts (and larger ones like ShortStat) rather than cluttering up my homepage. Really, how much absolute positioning and JavaScript can one take in a single sitting?
Here it is, revised one last time (although probably not the last time) to eliminate the “double-smack” of v1.5 in IE 5.5+ PC:
SI_clearAbsolutes v1.6 Packaged source. Just unzip, configure the SI_url
variable in the JavaScript file, upload to your server and then place the script
tag immediately before the closing body
tag of any document with absolutes to be cleared. Done.
Thanks to everyone who picked this script apart and provided alternate code to consider.
012 Comments
How about you keep them in .COM/MISERATE/ or .COM/POST/?
:D
Sweet, version 1.6 is nice.
Maybe the all the new stuff goes into .COM/PONENTS and then as the code withers or gets replaced with new code, it moves into the aforementioned .COM/POST heap.
So … hypothetically of course … let’s assume I wanted to clear just a specific DIV amongst a bunch of clearing and non-clearing absolutely positioned elements. (I’ve got some with negative margins that this seems to break.) How?
There’s the rub. The limitations of the current crop of browsers would require that the unique instances be classed and the script be modified to only touch the marked elements.
I could be missing something though.
Note: My solutions aim to work in as many modern browsers as possible, that means that any approach that relies on accessing computed CSS styles is not an option as versions of Safari—including the current 1.2 release—have no way of accessing this information. And I’m not about to neglect my primary browser. I am aware that the next version of Safari will have this ability but I have no intent of neglecting those who (rightly) refuse to pay for an OS upgrade just to update their browser (Bad Apple).
I frankly can’t get enough Javascript. And every time there’s no absolute positioning posts I cut my arms.
One way to do it is to presume that this is indeed an extension of HTML/XHTML and provide extra tags to describe the behavior.
This means creating a new DTD and a providing a new DOCTYPE definition, as well as, well, actually inventing the tags.
This is probably the way W3C wants you to handle this type of thing (look at XForms and MathML), but does it really warrant the hassle?
So you gonna build a: .com/(something witty that starts with com goes here) section of your site?
Just wondering if someone can help me clear the divs on the following web page: . www.victoriahealing.com/index.php
The instructions are real simple, so I don’t think I screwed them up. The footer, for whatever reasons, always appears on the top of the page??? The structure of the document is pretty simple as well.
does not work in IE6?
…..while it works okay with firefox 0.9 ….
Hmm, that’s weird. I’m pretty sure that worked fine when I originally posted this. The simple example still works. I was able to fix the nested example by adding a border or padding to the positioned divs.
It still looks a little different but that’s because of the way IE PC mishandles margins.
Hi,
I’ve tried to use this system to clear the bottom part of my page, where some absolutely positioned elements are hanging out of the containing box. I can’t seem to make it work though. Can someone please tell me what I’m doing wrong?
Cheers.