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)?
floating nav to the right with a fixed position? [closed]
Asked Answered
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;
}
exactly what I was looking for! –
Alphonsealphonsine
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)
Much better than the accepted answer. Thank you. –
Amaleta
© 2022 - 2024 — McMap. All rights reserved.
position:absolute
. – Gilleod