Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Navbar Coding (Basic i think!?)

Featured Replies

So i'm making a layout in photoshop and want to use the navbar i have attached in the picture... I've thought about every which way to code it inside of a div, but dont know which would be the proper way.

 

Ive thought of...

 

- Setting is as one image and mapping the links with a client side image map

- slicing is into individual links and setting the individually sliced images as seperate links

- taking the background and using it as the div background (repeat-x) and then making a horizontal unordered list to make up the links.

 

How would you code it?

Your advise would be fantastic :D

 

Big thanks

 

post-36486-0-20959700-1331860751_thumb.png

Simply UL and LI items wrapped within a div...

 

<div id="navbar">
<ul class="navigationbar">
<li class="navigationitem"> <a href="xxx" class="itemlink">Text here<br/>Second line here</a> </li>
<li class="navigationitem"> <a href="xxx" class="itemlink">Text here<br/>Second line here</a> </li>
<li class="navigationitem"> <a href="xxx" class="itemlink">Text here<br/>Second line here</a> </li>
</ul>
</div>

 

I would then use CSS to style each element.

With regards to custom fonts, check out google fonts or other similar websites.

 

Background imagery is simple to reproduce within either the DIV or the UL.

Personally, I would apply a background image to the UL... meaning the DIV can then be repositioned, resized, padded...etc.. without major worries.

 

That would be my chosen method... however recently, more and more I've seen websites using image based nav bars with "link mapping" over the images! Grrrrrrrrrrrrr

Edited by AlexsDesign

Simply UL and LI items wrapped within a div...

 

<div id="navbar">
<ul class="navigationbar">
<li class="navigationitem"> <a href="xxx" class="itemlink">Text here<br/>Second line here</a> </li>
<li class="navigationitem"> <a href="xxx" class="itemlink">Text here<br/>Second line here</a> </li>
<li class="navigationitem"> <a href="xxx" class="itemlink">Text here<br/>Second line here</a> </li>
</ul>
</div>

 

I would then use CSS to style each element.

With regards to custom fonts, check out google fonts or other similar websites.

 

Background imagery is simple to reproduce within either the DIV or the UL.

Personally, I would apply a background image to the UL... meaning the DIV can then be repositioned, resized, padded...etc.. without major worries.

 

That would be my chosen method... however recently, more and more I've seen websites using image based nav bars with "link mapping" over the images! Grrrrrrrrrrrrr

 

He could also use css sprite technique on the unordered list. It's quite ok way of doing it, with downside of having to off-set the actual text behind the frame.

 

http://www.alistapart.com/articles/sprites2

 

This could be one way of doing it, Kirk.

  • Author

Simply UL and LI items wrapped within a div...

 

<div id="navbar">
<ul class="navigationbar">
<li class="navigationitem"> <a href="xxx" class="itemlink">Text here<br/>Second line here</a> </li>
<li class="navigationitem"> <a href="xxx" class="itemlink">Text here<br/>Second line here</a> </li>
<li class="navigationitem"> <a href="xxx" class="itemlink">Text here<br/>Second line here</a> </li>
</ul>
</div>

 

I would then use CSS to style each element.

With regards to custom fonts, check out google fonts or other similar websites.

 

Background imagery is simple to reproduce within either the DIV or the UL.

Personally, I would apply a background image to the UL... meaning the DIV can then be repositioned, resized, padded...etc.. without major worries.

 

That would be my chosen method... however recently, more and more I've seen websites using image based nav bars with "link mapping" over the images! Grrrrrrrrrrrrr

 

 

Okay, this is what I originally thought would be the best way to do it! It seems a heck of a lot of others do it this way, I'm still trying to work out how to code the CSS, how do i put a space between the links so they're not all bunched up together in a row!??!

 

Thank you

Okay, this is what I originally thought would be the best way to do it! It seems a heck of a lot of others do it this way, I'm still trying to work out how to code the CSS, how do i put a space between the links so they're not all bunched up together in a row!??!

AlexsDesign said use CSS for each element.

.navigationitem { float: left; padding: 0 15px; }

That will place the li tags on the same line with 30px (2*15px) between them. You will need more CSS to fine tune the navbar.

  • Author

AlexsDesign said use CSS for each element.

.navigationitem { float: left; padding: 0 15px; }

That will place the li tags on the same line with 30px (2*15px) between them. You will need more CSS to fine tune the navbar.

 

Thank you, so how come when you right 15px it gives you thirty?

Every li tag has 15px padding at each side, so it will give you 15px padding at the left and right ends but twice 15px between each li tag. If you want a different padding at the left or right ends, give those li tags an extra class with a different padding-left or padding right.

  • Author

Every li tag has 15px padding at each side, so it will give you 15px padding at the left and right ends but twice 15px between each li tag. If you want a different padding at the left or right ends, give those li tags an extra class with a different padding-left or padding right.

 

 

Ohhh right, so it adds the padding both sides, that makes sense now! Cheers :D

If you can, use CSS instead of images. In this case, I'd be curious about the font. Do you plan to use it across the whole site? If so, consider using font-face. This allows you to load the font into your webpage and use it for text.

 

You'd then use CSS to make the nav, and use your font as the font-family for the links.

 

I don't have your font, but I rustled this up in five min: http://jsfiddle.net/2tVL8/1/

 

Used Alexsdesign markup, although slightly adjusted. Look ma, no images!

Edited by brightonmike

  • Author

If you can, use CSS instead of images. In this case, I'd be curious about the font. Do you plan to use it across the whole site? If so, consider using font-face. This allows you to load the font into your webpage and use it for text.

 

You'd then use CSS to make the nav, and use your font as the font-family for the links.

 

I don't have your font, but I rustled this up in five min: http://jsfiddle.net/2tVL8/1/

 

Used Alexsdesign markup, although slightly adjusted. Look ma, no images!

 

Thats excellent, its what im trying to create, but with the font 'Bank Gothic Medium'

 

The only thing is, if oyu look carefully at the navbar i uploaded, theeres a very slight pattern in the background, doesnt look like much as the navbar on its own, but does make a difference to the layout, but then i suppose, where you have put background:#color, i could just put

background:(url)link repeat-x;

couldnt i?

 

This is the bg file...

 

post-36486-0-72588000-1332019475_thumb.png

Edited by Kirk Freeman

Thats excellent, its what im trying to create, but with the font 'Bank Gothic Medium'

 

The only thing is, if oyu look carefully at the navbar i uploaded, theeres a very slight pattern in the background, doesnt look like much as the navbar on its own, but does make a difference to the layout, but then i suppose, where you have put background:#color, i could just put

background:(url)link repeat-x;

couldnt i?

 

This is the bg file...

 

post-36486-0-72588000-1332019475_thumb.png

 

That is correct.

  • Author

That is correct.

 

 

Nice, i just tried it out on Dreamweaver, and it does precisely what i want it to do, saweeeeet! One of my first topics on these forums n i learned something already! I could get used to this haha :) Hi five!

Thank you, so how come when you right 15px it gives you thirty?

 

I don't know if you are using Firebug or Chrome Developer Tools, but if you are not, start doing it! You will get the answer to such questions much more easily and quickly. Not that I want to discourage you to seek help on the forums. Just a suggestion that might improve your workflow ;)

I don't know if you are using Firebug or Chrome Developer Tools, but if you are not, start doing it! You will get the answer to such questions much more easily and quickly. Not that I want to discourage you to seek help on the forums. Just a suggestion that might improve your workflow ;)

 

IE developer tools will do it just as well.

  • Author

To be honest, and i dont know whether its just me, but i dislike IE with a passion! Am i own my own there?

To be honest, and i dont know whether its just me, but i dislike IE with a passion! Am i own my own there?

 

I second that, a browser that doesn't comply with web standards is something to really hate!

 

Fortunately there's plenty of workarounds to follow.

Edited by Dissident

IE9 is not too bad. I've never had a problem with it.

 

I meant earlier versions, such as IE 7-8, but it's improving drastically now with IE 9 and 10.

Edited by Dissident

  • Author

I meant earlier versions, such as IE 7-8, but it's improving drastically now with IE 9 and 10.

 

I haven't given IE9 a fair trial yet to be honest, so i shan't slag it off yet! But i think my favourite has to be safari!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.