|
Margin Problems in IE
I've decided to fix my previous problem by changing the dimensions of my layers from pixels, to percentages. So far things seem to be pretty good, except that the margins in IE are giving me some trouble. Specifically, even though the layer width is set to 100%, it doesn't go all the way to the other end of the window.
Under Mozilla, I don't have any problems... the layer goes right to the end as it's supposed to, and I don't have to worry about it. In IE, however, it's a different story.
I've fooled around with margin and padding settings in both a test script, as well as the site I'm building. In the test script, listed below, I am able to get the layer to actually get all the way across. But in my production site, no such luck:
code:
<HTML><HEAD><TITLE>Test Script</TITLE>
<SCRIPT LANGUAGE="javascript">
function createLayer(layerName,layerXPos,layerYPos,layerWidth,layerHeight,layerColor)
{
_TEMP_NEWLAYER = document.createElement("div");
_TEMP_NEWLAYER.setAttribute("id",layerName);
_TEMP_NEWLAYER.style.position = "absolute";
_TEMP_NEWLAYER.style.left = layerXPos + "%";
_TEMP_NEWLAYER.style.top = layerYPos + "%";
_TEMP_NEWLAYER.style.width = layerWidth + "%";
_TEMP_NEWLAYER.style.height = layerHeight + "%";
_TEMP_NEWLAYER.style.backgroundColor = layerColor;
document.body.appendChild(_TEMP_NEWLAYER);
}
function initPage()
{
document.body.bgColor = "#0000FF";
document.body.style.marginLeft = "0";
document.body.style.marginTop = "0";
document.body.style.marginRight = "0";
document.body.style.marginBottom = "0";
createLayer("layer01",0,50,100,20,"#FF0000");
}
</SCRIPT>
</HEAD>
<BODY onLoad="initPage()">
</BODY>
</HTML>
I'm defining the margins in initPage to simulate how my production site is generated. Basically I generate the page into a frame, using Javascript calls from another frame. Obviously the test script doesn't use frames... but it seems to work fine. Something else the test script doesn't do is load an external style sheet. My production site does. But would this make a difference? I even tried defining margin settings for the 'body' tag in my CSS file, but it didn't work at all.
So I presume that the reason this might not be working is either because of the stylesheet, or because of the frames. But how do I go about solving this problem?
Anyone have any ideas or insights?
Thanks,
-skubik.
|