CSS Floating Menu
This page contains code for a CSS floating menu bar. Also known as "fixed menus" and "hovering menus", floating menus stay in a fixed position when you scroll the page. They appear to "float" on top of the page as you scroll.
Creating a floating menu is very simple and quite painless. The operative code is
Example of a Floating Menu
The menu below an example of a floating menu. As you scroll down the page/(frame), you will notice the menu stays fixed in the same position on the page.
Click Preview to see the example in a full-sized screen.
Floating Menu Position
The above menu floats from its relative position on the page. That is, when the page loads, the menu first appears in the position it appears in the source code.
You can change this if needed.
right to position the menu exactly where you want it on the page. Regardless of where the menu is located within the source code, it will appear exactly as you specify it in the source code.
Here, we fix the menu to the bottom right of the page.
Feel free to change the width, color, and other properties as you wish. As long as you don't remove
position:fixed your menu should remain fixed.
How to Ensure the Menu is On Top
The above code uses
z-index to layer the menu on top of the other elements.
You may need to change this if you use other elements with a higher
z-index value. For example, if another element has a value of say,
200, you could make the menu
201 or even
2000 — as long as it's a higher value than the other elements it will remain on top.
Note that this code may not work in older browsers. This is because some older browsers don't support
position:fixed. If the above example doesn't work for you, this could be the reason.