tags:

views:

13

answers:

2

Help! This is my menu. I want it to stay at the same place, so if you resize it or drag the browser it shouldnt follow the browser and move the menu to the side

<div id="mainmenu" style="position: relative;">
<div id="menuLinks" style="position: absolute; right: 70px; top: 10px; ">
<a href="home.php">HEM</a>
<a href="#">PROFILER</a>
<a href="#">BILDER</a>
<a href="#">DISKOTEKER</a>
<a href="#">EVENTS</a>
<a href="#" class="menu_class">KONTROLLPANEL</a>
</div>

This works only if i change the div mainmenu line to:

<div id="mainmenu" style="position: relative; width: 1200px;">

(giving a width: ) then it stays at the place. But I do not want to specify width, because then it will end too early for some other screen resolutions and so..

How can i fix this?

A: 

Use position: absolute; for a fixed position within the document (will move scrolling the page).

Use position: fixed for a fixed position in the browser window. (won't move when scrolling the page)

In both cases, use left and top to specify the starting position.

You won't need to specify a width in either case.

position: fixed won't work in IE 6.

Pekka
I tried fixed, didnt affect it at all. I tried giving left instead of right, and that result that if i resize the menu are going downwards instead now
Karem
@Karem sorry, but a downvote because it didn't work on the first try is a bit rude, and not really an incentive to helping out any further. (If it is from you. If not, I apologize.)
Pekka
A: 

You can use position absolute and set the left attribute to whatever you measure it out to be and drop the right attribute.

But a better solution may be to use floating divs. It's impossible to tell though without looking at the rest of your code.

This is an interesting project you may be interested in. http://960.gs/

Maletor
floating divs ? like how? the left attribute just makes the menu goes downwards instead of going to the left(with right attribute)
Karem
This is a fantastic place: http://www.barelyfitz.com/screencast/html-training/css/positioning/
Maletor