Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Positioning error with CSS & JavaScript

Status
Not open for further replies.

BrotherPaul

Programmer
May 7, 2005
3
GB
Hi guys - very low-knowledge programmer here...

I'm trying to run an HTML page that utilises a JavaScript function to open a static menu bar dynamically (i.e. when you hover over a link, it will drop a list of menu items down to choose from).

The page can be found at:

- ignore the garbage writing underneath and the ugly colours.

My problem is I want the sub-menus to drop vertically down, not off-set as they are at the moment. Is this a problem with the position attribute in my style sheet?

The style sheet and JavaScript I use can be found at:


Any help would be really appreciated. Probably a simple answer but I never used to use style sheets so I'm very much a beginner!

Cheers,

Paul
 

Change this:

Code:
<body><center>

to this:

Code:
<body>

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Heh, cheers, I know that works, but the page needs to be centered! I'm a big fan of making concessions for different resolutions, so I try to center all my pages within a 800-width table, so it looks attractive for everyone.

Is there any way of making it work without centering the page?

Paul
 
so I try to center all my pages within a 800-width table, so it looks attractive for everyone

Attractive is a personal opinion, you know... Personally, I prefer left-justified.

And even if it weren't personal, using the center tag isn't thhe way to go - it works only in IE AFAIK - at least it didn't work in NN or FF, anyway.

Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
<div align="center"> is exactly the same as <center>

CENTER is obsolete but retained for backwards compatibility.

If you put a SPAN around the content inside the CENTER, then you can measure the obj.offsetLeft and position your dynamic elements with style.left

----------
Memoria mihi benigna erit qui eam perscribam
 
Your CSS is compressed and hard on the eyes, so I haven't looked at it. I also haven't looked at your JS.

The solution, however, might look like the following.

Code:
ELEMENT {
position:absolute;
left:expression(document.getElementById('yourSpan').offsetLeft);
}

It is potentially more complex than this depending on what exactly you have. Like I said, I didn't look.. because I have a headache and your files have been compressed to remove whitespace or something.

I hope this is helpful and that you can apply it to your project :)

----------
Memoria mihi benigna erit qui eam perscribam
 
Yeah, sorry about that, my text editor doesn't like whitespace for whatever reason. And incidentally, this isn't a project... (wish it was, it's a lot easier than what my uni's got me doing with a PHP website!).

Cheers for all the help guys, I've tried a few ideas and it's working pretty much how I want it to now. Really appreciate it.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top