floating nav to the right with a fixed position? [closed]
Asked Answered
P

2

21

My site navigation needs to be floated to the right side of the container, but be in a fixed position so that whenever the page scrolls, the navigation is still on the right 350px from the top. This worked until I applied position:fixed, after doing that the navigation is stuck on the right. Any ideas how I can have the best of both worlds(right side, and fixed position)?

http://jsfiddle.net/eeCgr/

Purpleness answered 20/2, 2013 at 23:16 Comment(2)
A good solution and very simple. Use it with position:absolute.Gilleod
It appears Vucko's link no longer works, and the project has moved to github.com/p-m-p/jQuery-StickyboxCulminate
L
53

The usage of position: fixed requires adjusting the top/right/bottom/left CSS to get your nav element to the desired location.

For example:

nav { 
    right: 0; 
    top: 50%; 
}

or

nav {
    right: 0; 
    top: 0;
}
Layby answered 20/2, 2013 at 23:22 Comment(1)
exactly what I was looking for!Alphonsealphonsine
H
3

Method X:

Just create the required division within another division.

Give postion:fixed; width:100%; properties to the outer div.

give float:right; property to the inside div.

Since the float and position properties are been given to two different divisions it would take effect. Make sure all other properties of the two divisions are identical.

(to hide the outer div, change its alpha value (a) of the color to 0.00 with HSLa code)

Happenstance answered 1/10, 2017 at 14:21 Comment(1)
Much better than the accepted answer. Thank you.Amaleta

© 2022 - 2024 — McMap. All rights reserved.