BullGuard Antivirus Sale - 60% Off with openElement !
Forum Home Forum Home >

openElement

> Scripts for Your Website
  New Posts New Posts RSS Feed - Fixed Navigation Bar
  FAQ FAQ  Forum Search   Register Register  Login Login

Fixed Navigation Bar

 Post Reply Post Reply
Author
Message
Chris OE View Drop Down
Admin Group
Admin Group


Joined: Jan 22 2013
Location: New York
Status: Offline
Points: 186
Post Options Post Options   Thanks (1) Thanks(1)   Quote Chris OE Quote  Post ReplyReply Direct Link To This Post Topic: Fixed Navigation Bar
    Posted: Aug 06 2013 at 6:33pm
Hello fellow openElementers,

Here is an easy to implement script for adding a fixed navigation bar to your website.  This means that it will always stay fixed at the top of the screen even as you scroll down past other content.  It can also be tweaked to become a left or right side nav bar, or even a footer that's always on screen. This is an HTML/CSS technique... Other solutions involving javascript and/or jQuery are also available.  http://www.thecodepress.info/2013/01/fixed-navigation-bar-in-css-html.html

For a barebones version, enter this into a regular visible Codeblock. Change categories as necessary - you can even use icons if you want:

<div id="nav">
<ul id="navigation">
 <li><a href="#">Home</a></li>
 <li><a href="#">Blog</a></li>
 <li><a href="#">Products</a></li>
 <li><a href="#">Downloads</a></li>
 <li><a href="#">About</a></li>
</ul>
</div>

Then, in a Hidden Codeblock, choose CSS as the script type and enter:

#nav
 {
 background-color:#262626;
 width:100%; /*this gives the navbar the entire width of its container*/
 height:50px; /*this is the height of the bar, for a sidebar change to 100pct and width to a specific value*/
 box-shadow: 0px 1px 50px #5E5E5E;
 position:fixed; /* this is the part that keeps the bar fixed to a point on the screen*/
 top:0px; /* this is the positioning of the bar, for a footer change to bottom*/
 left:0px;
 white-space:nowrap;
}

#navigation
{
 list-style-type:none; 
}
li 
{
 display:inline; /* this puts every LI in the UL in one line */
 padding:10px;
}

#nav a
{
 font-family:verdana;
 text-decoration:none;
 color:#EDEDED;
#nav a:hover 
{
 color:#BDBDBD;
}
body
{
margin-top:80px; /* this is so that the navbar doesn't cover the topmost content of the page */
}

You can change styles, colors and behavior as you see fit.
Back to Top
rob42 View Drop Down
Newbie
Newbie


Joined: Mar 12 2016
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote rob42 Quote  Post ReplyReply Direct Link To This Post Posted: Mar 12 2016 at 10:49am
Hi. This is such a simple and effective technique, very clever Clap; just what I was looking for. Thank you so much.


Edited by rob42 - Mar 12 2016 at 10:57am
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.