SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Jun 19, 2003, 09:02 #1
- Join Date
- Jun 2003
- Posts
- 30
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
positioning layers relatively to window size
Hi
I want my divs (position: absolute) to be positioned relatively to window size
My page is a main table with one cell containing all the rest
This cell (anf thus my page) is centered (top and left)
Each menu link has onMouseOver which shows (visibility) the corresponding layer (div)
Each visible/invisible layer is positioned on the same spot
I use absolute positioning for the divs because some browsers don't support positioning relative to tables
My question: is the following code the only solution or am I making my life (slightly) complicated over nothing?
This thing works on NN4, 6 7, IE 4, 5, PC and Mac -- that I know of; repositions divs onResize, with reLoad fix for !#+x°! NN4
I get the window size:
Code:function define_window() { if(document.layers||document.getElementById) { win_W = window.innerWidth; win_H = window.innerHeight; } if(document.all) { win_W = document.body.clientWidth; win_H = document.body.clientHeight; } }
Code:function position_layers() { winWidth = win_W; winHeight = win_H; var max_left = 220; var max_top = 140; horiz = Math.round((winWidth - 180) / 2); if(horiz < max_left) { horiz = max_left; } verti = Math.round(((winHeight - 220) / 2)); if(verti < max_top) { verti = max_top; } for(i=0;i<9;i++) { my_layer = 'div'+i budge(my_layer,horiz,verti) } }
So, your input is welcome.
Regards everyoneLast edited by pietro; Jun 19, 2003 at 10:18.
-
Jun 19, 2003, 18:23 #2
- Join Date
- Dec 2002
- Location
- Alabama, USA
- Posts
- 2,560
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi pietro, nice work.
Is it online?
-
Jun 20, 2003, 00:50 #3
- Join Date
- Jun 2003
- Posts
- 30
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well thanks
)
It's online, yes -- just one dead unfinished homepage I did for a job I was hoping to do, but didn't (client had one of his employees -- whose job is to do a bit of print layout -- do it for a cheaper price and the promise of fancy Flash pages)
Anyway, I'm sending you the url by private message (I'd rather keep it confidential as name of client appears on the page)
CheersLast edited by pietro; Jun 20, 2003 at 01:05.
Bookmarks