![]() Preserved Topic: Dynamic Positioning (Page 1 of 1) |
|
---|---|
Obsessive-Compulsive (I) Inmate From: New Orleans, LA, USA |
![]() I have a <DIV> tag that I would like to place 200px from the bottom of the browser window regardless of the screen resolution. I am using a CSS style sheet to position the <DIV>. |
Paranoid (IV) Mad Scientist From: Somewhere over the rainbow |
![]() The poster has demanded we remove all his contributions, less he takes legal action. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
![]() Nope, thankfully that's not all necessary. Most browsers support the "bottom" property: |
Maniac (V) Mad Scientist From: New California |
![]() I'll have to look into the bottom property some more. I wrote this cross-browser example up to help with this question: http://www.bugimus.com/gurus/center_div.html If all of this isn't necessary, that's quite cool but it usually depends on just how cross-browser your pages *needs* to be. If you're just writing for newer browsers, then by all means go for the simplest solution. |
Maniac (V) Inmate From: Brisbane, Australia |
![]() Just a small question on script bugs... |
Maniac (V) Mad Scientist From: New California |
![]() I honestly don't think it's worth doing the check for the page resize. I think that it would run a bit more efficiently but that depends on just how much work is involved with updating a div's position. I'm pretty sure the browser doesn't totally redraw the div when it repositions so I think repositioning it every 0.5 seconds is no big deal. |
Paranoid (IV) Mad Scientist From: Somewhere over the rainbow |
![]() The poster has demanded we remove all his contributions, less he takes legal action. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
![]() Really? Do you think the browser actually checks to see if its position is different every time you move it? |
Maniac (V) Mad Scientist From: Belgrade, Serbia |
![]() Some time ago, I have tested these two approaches (letting timer run constantly and aborting if size didn't change) on "BrotherCake Ultimate DropDown Menu" (I had to modify that script by myself) and my conclusion was that it's best to check if size has actually changed. Although web browsers may not redraw layers if they stay on same position, a lot of JavaScript code still has to be parsed and that puts *a lot* of pressure on the CPU... |
Paranoid (IV) Mad Scientist From: Somewhere over the rainbow |
![]() The poster has demanded we remove all his contributions, less he takes legal action. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
![]() Oh, I'm sure the browser doesn't constantly redraw *every* element, but I think if it came across a javascript statement that changed the position of an element, it would consider that element to have moved without actually checking if you moved it to a different place than it already was or not. That way it can just keep a boolean value for each element on the page, keeping track of whether it needs to be redrawn or not, and if you change a style property of an element it sets that boolean to true. Then it just redraws all elements for which that boolean is true. |