NBostaph
06-14-2009, 07:46 PM
This is probably a relatively simple problem, but I'm not a CSS expert and it's been driving me absolutely insane for hours. Because I can't think of any good word to describe my problem besides "float", and that's an actual property name, my searches are coming up empty too. My sincerest appreciation to anyone who can shed some light on what I'm doing wrong.
I have the following pieces of code in a webpage:
function buildDimmerDiv() {
document.write('<div id="dimmer" class="dimmer" style="width:'+
window.screen.width + 'px; height:' + window.screen.height +'px; position:fixed; display:none;"></div>');
document.getElementById('dimmer').style.opacity = 0.00;
}
function dimpage() {
document.getElementById('dimmer').style.visibility = "visible";
document.getElementById('dimmer').style.display = "block";
dimmore();
}
function dimmore() {
document.getElementById('dimmer').style.opacity = parseFloat(document.getElementById('dimmer').style.opacity) + 0.05;
if (document.getElementById('dimmer').style.opacity < 0.85) {setTimeout("dimmore()", 25);}
}
buildDimmerDiv();
You can build a sample testing page using this code, though it will require a black image called dimmer.png:
<STYLE>
div.dimmer
{
visibility: hidden;
position:absolute;
left:0px;
top:0px;
font-family:verdana;
font-weight:bold;
padding:40px;
opacity:0.05;
background-image:url(imgs/dimmer.png);
/* ieWin only stuff */
/* with this trick only IE
manage the following 2 attributes */
filter:alpha(opacity=5)
_background-image:none;
_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader
(enabled=true, sizingMethod=scale src='dimmer.png');
}
</STYLE>
Text 1
<SCRIPT>
function buildDimmerDiv() {
document.write('<div id="dimmer" class="dimmer" style="width:'+
window.screen.width + 'px; height:' + window.screen.height +'px; position:fixed; display:none;"></div>');
document.getElementById('dimmer').style.opacity = 0.00;
}
function dimpage() {
document.getElementById('dimmer').style.visibility = "visible";
document.getElementById('dimmer').style.display = "block";
dimmore();
}
function dimmore() {
document.getElementById('dimmer').style.opacity = parseFloat(document.getElementById('dimmer').style.opacity) + 0.05;
if (document.getElementById('dimmer').style.opacity < 0.85) {setTimeout("dimmore()", 25);}
}
buildDimmerDiv();
</SCRIPT>
Text 2
<SPAN ONCLICK="dimpage();" STYLE="cursor:pointer;">Click Here</SPAN>
In firefox and Chrome, when the dimpage function is called, the entire page appears to fade to darkness and then I can have another function make a content div visible to show some content over the faded area. This is exactly how I want it to work.
However, in IE8 (and I assume previous versions), when I call the dimpage function a black box the size of the page immediately appears, then under that the content div appears under that, and the rest of the page's existing content is pushed down even further. Obviously not how I want it to work.
The problem simply has to do with the fact that these divs are floating over the content in FF and Chrome, while in IE they are seen as elements that the rest of the page must flow around. The question I've been unable to answer: how do I make them 'float' above the content in IE like they do in FF and Chrome?
I know the opacity thing doesn't work in IE either, but I'm pretty sure I can figure that part out on my own later.
Thanks for reading.
I have the following pieces of code in a webpage:
function buildDimmerDiv() {
document.write('<div id="dimmer" class="dimmer" style="width:'+
window.screen.width + 'px; height:' + window.screen.height +'px; position:fixed; display:none;"></div>');
document.getElementById('dimmer').style.opacity = 0.00;
}
function dimpage() {
document.getElementById('dimmer').style.visibility = "visible";
document.getElementById('dimmer').style.display = "block";
dimmore();
}
function dimmore() {
document.getElementById('dimmer').style.opacity = parseFloat(document.getElementById('dimmer').style.opacity) + 0.05;
if (document.getElementById('dimmer').style.opacity < 0.85) {setTimeout("dimmore()", 25);}
}
buildDimmerDiv();
You can build a sample testing page using this code, though it will require a black image called dimmer.png:
<STYLE>
div.dimmer
{
visibility: hidden;
position:absolute;
left:0px;
top:0px;
font-family:verdana;
font-weight:bold;
padding:40px;
opacity:0.05;
background-image:url(imgs/dimmer.png);
/* ieWin only stuff */
/* with this trick only IE
manage the following 2 attributes */
filter:alpha(opacity=5)
_background-image:none;
_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader
(enabled=true, sizingMethod=scale src='dimmer.png');
}
</STYLE>
Text 1
<SCRIPT>
function buildDimmerDiv() {
document.write('<div id="dimmer" class="dimmer" style="width:'+
window.screen.width + 'px; height:' + window.screen.height +'px; position:fixed; display:none;"></div>');
document.getElementById('dimmer').style.opacity = 0.00;
}
function dimpage() {
document.getElementById('dimmer').style.visibility = "visible";
document.getElementById('dimmer').style.display = "block";
dimmore();
}
function dimmore() {
document.getElementById('dimmer').style.opacity = parseFloat(document.getElementById('dimmer').style.opacity) + 0.05;
if (document.getElementById('dimmer').style.opacity < 0.85) {setTimeout("dimmore()", 25);}
}
buildDimmerDiv();
</SCRIPT>
Text 2
<SPAN ONCLICK="dimpage();" STYLE="cursor:pointer;">Click Here</SPAN>
In firefox and Chrome, when the dimpage function is called, the entire page appears to fade to darkness and then I can have another function make a content div visible to show some content over the faded area. This is exactly how I want it to work.
However, in IE8 (and I assume previous versions), when I call the dimpage function a black box the size of the page immediately appears, then under that the content div appears under that, and the rest of the page's existing content is pushed down even further. Obviously not how I want it to work.
The problem simply has to do with the fact that these divs are floating over the content in FF and Chrome, while in IE they are seen as elements that the rest of the page must flow around. The question I've been unable to answer: how do I make them 'float' above the content in IE like they do in FF and Chrome?
I know the opacity thing doesn't work in IE either, but I'm pretty sure I can figure that part out on my own later.
Thanks for reading.