Connecting Tech Pros Worldwide Forums | Help | Site Map

Setting <div> margin for NN4

Ian Rastall
Guest
 
Posts: n/a
#1: Jul 20 '05
This really is a JavaScript question. I have a site that looks fine in
everything but NN4. I'm afraid I don't have a URL, because the site is
very much unfinished.

The site is a header (which is a table) and a main <div> underneath
that. The main <div> is set to have a top margin of 3%, which works
fine, except in NN4. There, it looks like it has a margin of 20%, or
even larger.

I couldn't fix it with the @import hack, so I thought I might try
JavaScript. I tried something like this:

<script language="JavaScript" type="text/javascript">
if (document.layers) frank.styles.margin-top = "-20%"
</script>

(I called the <div> "frank" ...)

I'm very sorry, because I'm almost certain this isn't real JavaScript.
I'm just shooting in the dark. Is this *going* in the right direction,
or is this approach completely flawed? Would NN4 even understand
something like this?

TIA

Ian
--
http://www.aspipes.org/
http://www.bookstacks.org/

Dom Leonard
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Setting <div> margin for NN4


Ian Rastall wrote:[color=blue]
>
> The site is a header (which is a table) and a main <div> underneath
> that. The main <div> is set to have a top margin of 3%, which works
> fine, except in NN4. There, it looks like it has a margin of 20%, or
> even larger.
>
> I couldn't fix it with the @import hack, so I thought I might try
> JavaScript. I tried something like this:
>
> <script language="JavaScript" type="text/javascript">
> if (document.layers) frank.styles.margin-top = "-20%"[/color]
AFAIK you can only access a DIV element through javascript in NS4 if it
is positioned. If it *is* positioned, then
if(document.layers)
document.layers['frank'].style.marginTop=....;
might get you access to the style object property of the layer and set
its top margin. At the same time, a positioned element might better
placed using top and left properties than margin. [Note javascript style
properties use interCaps spelling to replace CSS hyphenated names.]

<snip>

Would NN4 even understand[color=blue]
> something like this?
>[/color]

Probably not. NS4 used CSS positioning before it became standardised,
and has multiple errors and inconsistencies with standard CSS.

To understand what NS4 *might* be doing with your percentage values,
take a Header element like
<h1 style="font-size:200%">Hello</h1>
The percentage size is calculated on the default font-size of H1 and not
the containing body (resulting in a font size of 400% for the H1
element.) This taking base percentage from the wrong place and generally
getting inheritance wrong or losing track of it is a big feature of NS4.
Even with care, absolute measurements (px or pt) may be required for NS4.

The other alternative is to put *all* CSS in the stylesheet, and use
@media rules to make sure *none* of it is visible to NS4, which can then
render using its default style sheet and present like a version 3 browser.

Dom

Ian Rastall
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Setting <div> margin for NN4


On Fri, 04 Jul 2003 14:25:02 +0930, Dom Leonard
<doml.removethis@senet.andthis.com.au> wrote:
[color=blue]
>Ian Rastall wrote:[color=green]
>>
>> The site is a header (which is a table) and a main <div> underneath
>> that. The main <div> is set to have a top margin of 3%, which works
>> fine, except in NN4. There, it looks like it has a margin of 20%, or
>> even larger.
>>
>> I tried something like this:
>>
>> <script language="JavaScript" type="text/javascript">
>> if (document.layers) frank.styles.margin-top = "-20%"
>>[/color]
>AFAIK you can only access a DIV element through javascript in NS4 if it
>is positioned.[/color]

Thanks, Dom. I might give relative positioning a shot, although I'll
never mess with absolute positioning again. The last thing I want is
to mess up the site on every other browser. It isn't like NS4 is being
used that much anymore.

It's the allure of desktop-publishing-style consistency. I have that
with every other browser I've tested.

Thanks again,

Ian
--
http://www.aspipes.org/
http://www.bookstacks.org/
Ian Rastall
Guest
 
Posts: n/a
#4: Jul 20 '05

re: Setting <div> margin for NN4


On Fri, 04 Jul 2003 01:22:26 -0400, Ian Rastall
<idrastall@earthlink.net> wrote:
[color=blue]
>Thanks, Dom. I might give relative positioning a shot[/color]

Sorry to respond to my own post ... and man, I hate to post this on a
JavaScript ng, but I found a solution (in CSS). This is a hack I ran
across on a Google search. If you were to type:

div.text {/;margin-top: 3%;}

every browser would understand this *except* for NS4. So there you go.
I now return you to a JavaScript discussion. <grin>

Ian
--
http://www.aspipes.org/
http://www.bookstacks.org/
Ian Rastall
Guest
 
Posts: n/a
#5: Jul 20 '05

re: Setting <div> margin for NN4


On Fri, 04 Jul 2003 12:02:01 +0200, Martin Honnen
<Martin.Honnen@t-online.de> wrote:
[color=blue]
>Thus if you have a div that is not positioned no script in NN4 is able
>to change any style of it.
>Even if the div were positioned you could only change the visibility and
>the clipping but not margins.[/color]

Thanks, Martin.

Ian
--
http://www.aspipes.org/
http://www.bookstacks.org/
Closed Thread