Rob Johnson

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromRob Johnson
ToMe
SubjectFixed postion script
Date11 May 2006 16:48
Hello Mark.

Your fixed postion script is great! But I have been trying to make a DIV
layer be fixed to the left side and vertically centered. Would this be an
easy mod?


A future suggestion: would be really cool to have a location varialbe.

i.e.

/*
top-left
top-center
top-right
left-middle
center
right-middle
bottom-left
bottom-center
right-center
*/

var location = 'top-left';

Cheers!!!

Rob
FromMe
ToRob Johnson
SubjectRe: Fixed postion script
Date12 May 2006 10:00
Rob,

> I have been trying to make a
> DIV layer be fixed to the left side and vertically centered.

This option is not built directly into the script, but should be a fairly
simple modification. Change this:

myLogo.top = ( yOf + ( ( p < 3 ) ? 0 : scrH - h ) + ( s ? scrOfY : 0 ) ) +
oPix;

to this:

myLogo.top = ( ( ( scrH - h ) / 2 ) + ( s ? scrOfY : 0 ) ) + oPix;

> A future suggestion

I will not make any more modifications to this script, and I am due to
retire it fairly soon. The simple reason is that IE 7 has finally
implemented fixed positioning. It was previously the only current browser
that failed to do this. With position:fixed it is this easy to position it
in the position you wanted:

<div style="height:26px;position:fixed;top:50%;left:0;margin-top:-13px;">
  test
</div>

The script itself is merely a poor substitute for fixed positioning, and was
written only to fill the gap while we waited for IE to catch up with the
other browsers. Now that that is due to happen, the script is no longer the
right way to do things. IE users should be encouraged to upgrade to IE 7,
and if they are on a platform where IE 7 is not being released (Windows
2000, for example), they should be encouraged to switch to a browser that
does not abandon current operating systems, such as Opera or Firefox.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromRob Johnson
ToMe
SubjectRe: Fixed postion script
Date12 May 2006 11:40
Hi Tarquin,

It's cool with me. I see eye to eye with you and really appreciate you were
very kind to explain your reasons below.

You are right about the translation workflow, it can take some time and one
has to be on top of it to manage changes of content as the material evolves.

Many thanks indeed for making this tutorial/course available for all of us.
Keep up the good work!

Best regards,

Luis
FromMe
ToRob Johnson
SubjectRe: Fixed postion script
Date12 May 2006 15:06
Hey Tarquin.

Thanks for the quick reply :)

I may be missing something, but how does the below
example fit into your current script (in the "if IE
5.5 or 7" conditional statement)?:
FromRob Johnson
ToMe
SubjectRe: Fixed postion script
Date14 May 2006 13:01
Rob,

> I may be missing something, but how does the below
> example fit into your current script (in the "if IE
> 5.5 or 7" conditional statement)?:

ah, sorry, when you said "script" I thought you were referring to the script
that runs in all browsers, not the IE hack. totally different thing :)

ok, well, it should be a similar idea to what I already use, but it is
certainly not pretty, since it means measuring yet more details of the
browser window. To be honest, at this stage I will warn you against trying
what you are attempting to do. You are pushing the limits of what is already
a very ugly hack. You are almost certainly going to run into bugs somewhere.

Anyway, here's the code;

<style type="text/css">
#fixme {
  /* margin is half of height, negative */
  position: absolute;
  left: 0px;
  top: 50%;
  height: 40px;
  margin-top: -20px;
}
body > div#fixme {
  position: fixed;
}
</style>
<!--[if gte IE 5.5]>
<![if lt IE 7]>
<style type="text/css">
div#fixme {
  /* IE5.5+/Win - this is more specific than the IE 5.0 version */
  left: expression( ( ignoreMe2 = document.documentElement.scrollLeft ?
document.documentElement.scrollLeft : document.body.scrollLeft ) + 'px' );
  top: expression( ( ( ( document.documentElement.clientHeight ?
document.documentElement.clientHeight : document.body.clientHeight ) / 2 )
+ ( ignoreMe = document.documentElement.scrollTop ?
document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
}
</style>
<![endif]>
<![endif]-->
FromMe
ToRob Johnson
SubjectRe: Fixed postion script
Date15 May 2006 18:32
Great, thanks Tarquin!

Rob
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.