Welcome Guest!
Please login
If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:
- Receive Fast Advice
- Learn Programming Languages
- Get Professional Website Reviews
- Quick Troubleshooting Assistance
|
|
Fit Element To Page Size In Ie6
This is a discussion on Fit Element To Page Size In Ie6, within the Javascript section. This forum and the thread "Fit Element To Page Size In Ie6" are both part of the Programming Your Website category.
![]() ![]() |
May 29 2008, 05:35 AM
Post
#1
|
|
|
Squeezing ![]() ![]() ![]() Group: Members Posts: 59 Joined: 18-February 08 Member No.: 169 |
I'm trying to get an Element to fit to the page size when the window is resized in IE6. Unfortunately, it seems that when calculating the page size IE6 calculates it with the Element still taking up the size it was before the window was resized, even though I am telling it not to. I have tried setting the element display to 'none' instead of resizing it to 0px, but still the same problem.
Hope someone can help me! Dave CODE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html> <head> <title>Untitled Page</title> <style type="text/css"> body, html { margin: 0; padding: 0; height: 100%; } #lbContainer { background-color: #000; filter: alpha(opacity=70); z-index: 2; position: absolute; top: 0; left: 0; } </style> <script type="text/javascript"> window.onresize = function() { var lbContainer = document.getElementById('lbContainer'); lbContainer.style.width = 0; lbContainer.style.height = 0; resize(); } function resize() { var lbContainer = document.getElementById('lbContainer'); var pageSize = getPageSize(); lbContainer.style.width = pageSize[0]; lbContainer.style.height = pageSize[1]; } function getPageSize() { return new Array(document.documentElement.scrollWidth, document.documentElement.scrollHeight); } </script> </head> <body> <div id="lbContainer"></div> </body> </html> This post has been edited by djeyewater: May 30 2008, 09:29 AM |
|
|
May 29 2008, 05:43 AM
Post
#2
|
|
|
Rapid Squeezer ![]() ![]() ![]() ![]() Group: Advisors Posts: 275 Joined: 15-February 08 From: Finland Member No.: 139 |
You don't need that javascript. Just put height:100%; width:100%; to the container. Also remember to set body/html to height:100% for it to work.
-------------------- anttisimonen.com - .NET developer
anttis.wordpress.com - Blog |
|
|
May 29 2008, 06:49 AM
Post
#3
|
|
|
Squeezing ![]() ![]() ![]() Group: Members Posts: 59 Joined: 18-February 08 Member No.: 169 |
Thanks for your help, but the element has a z-index of 2 (sorry, forgot to put this in my example), so when setting size to 100%, it is set to 100% of window size rather than page size.
Dave |
|
|
May 30 2008, 05:32 AM
Post
#4
|
|
|
Squeeze Machine ![]() ![]() ![]() ![]() ![]() Group: Mentor Posts: 602 Joined: 15-February 08 From: UK Member No.: 143 |
Thanks for your help, but the element has a z-index of 2 (sorry, forgot to put this in my example), so when setting size to 100%, it is set to 100% of window size rather than page size. Dave But your z-index doesn't do anything! Z-index only affects positioned elements, and your container is not positioned. Besides, all other box formatting should be applied independently of the stacking order. Antti's solution (height: 100%; width: 100%) should work here. This post has been edited by MikeHopley: May 30 2008, 05:33 AM |
|
|
May 30 2008, 09:29 AM
Post
#5
|
|
|
Squeezing ![]() ![]() ![]() Group: Members Posts: 59 Joined: 18-February 08 Member No.: 169 |
But your z-index doesn't do anything! Z-index only affects positioned elements, and your container is not positioned. Besides, all other box formatting should be applied independently of the stacking order. Antti's solution (height: 100%; width: 100%) should work here. Oops, sorry, it's absolutely positioned (forgot that in my example as well!) |
|
|
May 30 2008, 10:05 AM
Post
#6
|
|
|
Squeeze Machine ![]() ![]() ![]() ![]() ![]() Group: Mentor Posts: 602 Joined: 15-February 08 From: UK Member No.: 143 |
Oops, sorry, it's absolutely positioned (forgot that in my example as well!) Why is it absolutely positioned? What are you trying to achieve? You're drip-feeding us information here. Can you supply a link to a test page, and an expanation of what you're trying to do? Absolute positioning is greatly overused by CSS beginners. Most of the time it's harmful. |
|
|
Jun 1 2008, 04:10 AM
Post
#7
|
|
|
Squeezing ![]() ![]() ![]() Group: Members Posts: 59 Joined: 18-February 08 Member No.: 169 |
Why is it absolutely positioned? What are you trying to achieve? You're drip-feeding us information here. Can you supply a link to a test page, and an expanation of what you're trying to do? Absolute positioning is greatly overused by CSS beginners. Most of the time it's harmful. Here's a test page: http://www.brighton360.com/IE6test/Untitled%20Document.htm Basically I'm just trying to create an overlay for a lightbox effect. |
|
|
Jun 1 2008, 04:41 AM
Post
#8
|
|
|
Squeeze Machine ![]() ![]() ![]() ![]() ![]() Group: Mentor Posts: 602 Joined: 15-February 08 From: UK Member No.: 143 |
Here's a test page: http://www.brighton360.com/IE6test/Untitled%20Document.htm Basically I'm just trying to create an overlay for a lightbox effect. I think you should read this article. |
|
|
Jun 1 2008, 01:51 PM
Post
#9
|
|
|
Squeezing ![]() ![]() ![]() Group: Members Posts: 59 Joined: 18-February 08 Member No.: 169 |
|
|
|
Jun 2 2008, 04:27 AM
Post
#10
|
|
|
Squeeze Machine ![]() ![]() ![]() ![]() ![]() Group: Mentor Posts: 602 Joined: 15-February 08 From: UK Member No.: 143 |
|
|
|
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
1 | thunderrabbit | 221 | 13th February 2008 - 11:21 PM Last post by: Jacob |
|||
![]() |
13 | Rakuli | 500 | 19th February 2008 - 09:53 AM Last post by: karinne |
|||
![]() |
11 | unitedcraig | 320 | 15th February 2008 - 06:08 PM Last post by: unitedcraig |
|||
![]() |
8 | Daniela | 380 | 18th February 2008 - 05:28 PM Last post by: Jasontor |
|||
![]() |
16 | thewal | 522 | 19th February 2008 - 02:34 PM Last post by: thewal |
|||






May 29 2008, 05:35 AM







