You are here: Skinyourscreen.comWeb DesignHints, Tips, & TricksTopic: Fixed location menu using CSS
Pages: [1]
Fixed location menu using CSS
  • mrbiotech
  • Administrator
  • Hero Member
  • *****
  • Karma: 25
  • Offline Offline
  • Posts: 560
  •  
  • View Profile WWW
Fixed location menu using CSS
« on: April 29, 2006, 06:06:45 PM »


Here's a little something I've posted on my blog about generating a nifty fixed menu.  This will let you have a menu for your web-pages that stays stuck to the top part of the browser window.    You can see a working example of this on my blog - you'll see that when you scroll through the web-page, the menu stays put.  Note:  Internet Explorer does not support this feature due to crappy compliance to web-standards by Microsoft.

Below are the CSS styles used to generate the effect.  You can use the in-header method or use a call in your header to point to a separate CSS style sheet to access these.

Code:
/*===[ Top Navigation Bar Styles]===*/
.horzmenu {
position: fixed;
left: 0px;
top: 0px;
background-color: #222;
font-size: 12px;
width: 100%;
height: 1.3em;
border: 3px solid #777;
margin: 0px;
padding: 5px;
}
.horzmenu li {
width: 142px;
height: 49px;
color: #fff;
display: inline;
}
.horzmenu a {
padding: 0px;
margin: 0px 5px;
border-bottom: 3px solid #444;
text-decoration: none;
}
.horzmenu a:link { /* unvisited link */
color: #aaa;
height: 49px;
width: 149px;
}
.horzmenu a:visited { /* visited link */
color: #889;
}
.horzmenu a:hover { /* mouse over link */
border-bottom: 3px solid #f90;
color: #fff;
}
.horzmenu a:active { /* selected link */
background-color: #333;
color: #fff;
border-bottom: 3px solid #444;
}

The part that works the magic is the first style, the .horzmenu style.  This style represents a container, or box, that spans the width of the browser and is told to stick to the top of the browser window using the position: fixed; parameter.

The remainder of the styles essentially format the links and list items within that container.  Note that the list items within the .horzmenu container (the .horzmenu li style) have the display: inline; parameter set, which specifies that rather than creating a vertical bulleted list, they will spread horizontally.

Now here's the code in the body of the XHTML file.  It's basically just an unordered (bulleted) list using the styles above, and the links can easily be changed to suit your needs:

Code:
<!-- My custom Skinyourscreen.com links -->
<div class="horzmenu">
<ul class="nav_ul">
<li><a href="http://skinyourscreen.com/site" alt="SYS">Skinyourscreen</a></li>
<li><a href="http://skinyourscreen.com/podcasts" alt="Podcast">SYS Podcast</a></li>
<li><a href="http://skinyourscreen.com/skinwiki" alt="SkinWiki">SkinWiki</a></li>
<li><a href="mailto:mrbiotech@skinyourscreen.com" alt="Contact Me">Contact me</a></li>
</ul>
</div>

It's a very simple effect, but you might imagine what one could accomplish using this technique with some nicely shadowed alpha-transparent PNG images (something else the worthless Internet Explorer browser can't easily handle).  This could also easily be used to create a fixed column on the left or right side of the browser window, or even a fixed-position menu at the bottom of the browser.
Logged

  • Nerio
  • Global Moderator
  • Sr. Member
  • *****
  • Karma: 65535
  • Offline Offline
  • Posts: 297
  • Still Alive!!
  •  
  • View Profile WWW
Re: Fixed location menu using CSS
« Reply #1 on: September 14, 2006, 03:51:35 AM »

even am a wiser person to do such things Huh, it was very informatif....but the code is writen too smal Tongue Afro
Logged

Still Alive!!
  • mrbiotech
  • Administrator
  • Hero Member
  • *****
  • Karma: 25
  • Offline Offline
  • Posts: 560
  •  
  • View Profile WWW
Re: Fixed location menu using CSS
« Reply #2 on: September 14, 2006, 08:37:29 AM »

I agree... ported this code from Blogger, and it looks like it messed it up a little.

If using Mozilla FireFox you can press CTRL and + at the same time to increase font size for readability purposes.  This remedied it for me, but I'll still look into the article coding/site CSS to see if there are any other ways to resolve it.
Logged

  • Axeman747
  • Newbie
  • *
  • Karma: 11
  • Offline Offline
  • Posts: 15
  •  
  • View Profile
Re: Fixed location menu using CSS
« Reply #3 on: September 14, 2006, 02:11:06 PM »

Rich you may want to take a look at the Forum CSS file and change the size and color there. Even if the color was brighter I think it would be better.  Cool
Logged
  • mrbiotech
  • Administrator
  • Hero Member
  • *****
  • Karma: 25
  • Offline Offline
  • Posts: 560
  •  
  • View Profile WWW
Re: Fixed location menu using CSS
« Reply #4 on: September 16, 2006, 10:27:13 PM »

Can do. Dunno how it ended up so dark in the first place.  Workin' on it now Smiley
Logged

  • Axeman747
  • Newbie
  • *
  • Karma: 11
  • Offline Offline
  • Posts: 15
  •  
  • View Profile
Re: Fixed location menu using CSS
« Reply #5 on: September 16, 2006, 10:33:31 PM »

That looks very nice. Easy to read anad matches the theme very well.
Logged
  • mrbiotech
  • Administrator
  • Hero Member
  • *****
  • Karma: 25
  • Offline Offline
  • Posts: 560
  •  
  • View Profile WWW
Re: Fixed location menu using CSS
« Reply #6 on: September 16, 2006, 10:33:41 PM »

Okay, I changed the "Code" colors to more emulate an old-school DOS terminal ('cuz sometimes, I miss the old DOS terminal).  Green on Black for now, but I'm taking requests Wink
Logged

  • mrbiotech
  • Administrator
  • Hero Member
  • *****
  • Karma: 25
  • Offline Offline
  • Posts: 560
  •  
  • View Profile WWW
Re: Fixed location menu using CSS
« Reply #7 on: September 16, 2006, 10:34:18 PM »

For some reason it doesn't want to update in Safari, although it looks fine in FireFox.  Odd, huh?
Logged

  • Nerio
  • Global Moderator
  • Sr. Member
  • *****
  • Karma: 65535
  • Offline Offline
  • Posts: 297
  • Still Alive!!
  •  
  • View Profile WWW
Re: Fixed location menu using CSS
« Reply #8 on: September 17, 2006, 05:48:23 AM »

even in old IE versions the look is better now......the old dos look is a very interessting font type...and sometimes i run dos just to look at it again  Grin Grin Grin Grin Grin Grin Afro
Logged

Still Alive!!
  • mrbiotech
  • Administrator
  • Hero Member
  • *****
  • Karma: 25
  • Offline Offline
  • Posts: 560
  •  
  • View Profile WWW
Re: Fixed location menu using CSS
« Reply #9 on: September 17, 2006, 10:12:03 AM »

Since I've started using Linux and Mac OS X I've again found the terminal/command-line to be an invaluable tool.  Sure, using a GUI is fun and intuitive, but I can accomplish certain tasks 3-5 times faster using a terminal.

Glad the newer look is rendering for you guys.  Lemme know if you come across anything else odd Smiley
Logged

  • Nerio
  • Global Moderator
  • Sr. Member
  • *****
  • Karma: 65535
  • Offline Offline
  • Posts: 297
  • Still Alive!!
  •  
  • View Profile WWW
Re: Fixed location menu using CSS
« Reply #10 on: September 17, 2006, 03:35:59 PM »

in the old site layout, the one in the grey, some buttons displacements here and there...but this one is better !!!
Logged

Still Alive!!
  • mickeblue
  • Sr. Member
  • ****
  • Karma: 60004
  • Offline Offline
  • Posts: 437
  •  
  • View Profile WWW
Re: Fixed location menu using CSS
« Reply #11 on: October 23, 2006, 09:19:50 AM »

Neat, sweet & quite petite  Grin
Logged

  • mrbiotech
  • Administrator
  • Hero Member
  • *****
  • Karma: 25
  • Offline Offline
  • Posts: 560
  •  
  • View Profile WWW
Re: Fixed location menu using CSS
« Reply #12 on: October 25, 2006, 06:49:08 PM »

Gratzi!  There's a lot of fun things one can do with CSS like this, if your users don't use the acursed InternetExplorer.
Logged

Re: Fixed location menu using CSS
« Reply #13 on: January 29, 2007, 03:24:38 AM »

*shakes fist at IE*
It's a pity IE only supports background-attachment:fixed for the body element. I've seen some very creative uses of CSS that simply cannot be, due to IE's CSS support or lack thereof.

http://meyerweb.com/eric/css/ -> if you haven't already, check out some of the CSS demos here.
Logged

Tandis qu'ils dorment, nous gagnerons.
[ lws.nfshost.com | liaung [at] nospam gmail.com ]
  • mickeblue
  • Sr. Member
  • ****
  • Karma: 60004
  • Offline Offline
  • Posts: 437
  •  
  • View Profile WWW
Re: Fixed location menu using CSS
« Reply #14 on: March 03, 2007, 05:04:37 AM »

That's a cool link Wes
Logged

Pages: [1]
You are here: Skinyourscreen.comWeb DesignHints, Tips, & TricksTopic: Fixed location menu using CSS
Jump to: