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.

nav bar with css / images

Featured Replies

Hi All,

 

I’m in the process of creating my nav bar for my very first website. I want to create my horizontal nav bar containing my 5 links. I don’t want to replace images with CSS or Java, just hide the non active portion of the image as this seems to be the best way.

 

Do I have to create 5 divs (within a nav div) for my images to go into as backgrounds, or 1 div for main nav bar image etc..?

I want to use image or images – not text links.

I also want to have a un-hover, hover and active state – with hove/active being the same effect.

 

I’ve looked for other examples but all seem to use text links instead of separate images!! Anybody have the code for this?

 

 

Cheers

Hey!

 

You can use a div called nav then put the images in the div. Probably best to use and unordered list too <ul>

 

 <div id="nav"><ul><li><a href="whatever.html"> <img src="images/pic.png" height="..." width="..." alt="Home Tab" /></a></li>.......</ul></div>

Insert sizes of images where the ... is. Make sure each image/ link combo is surrounded by <li> then </li>.

 

Then for your css

#nav a {
		 text-decoration: none;
}
#nav a img {
		border: none;
}
#nav ul {
	   display: inline;
}

 

That's only the very basics and presuming you don't want the default outline on the image and the nav to be horizontal.

 

Ask if you need more help, tell me if I haven't answered your question...

 

All the best :)

  • Author
Hey!

 

You can use a div called nav then put the images in the div. Probably best to use and unordered list too <ul>

 

 <div id="nav"><ul><li><a href="whatever.html"> <img src="images/pic.png" height="..." width="..." alt="Home Tab" /></a></li>.......</ul></div>

Insert sizes of images where the ... is. Make sure each image/ link combo is surrounded by <li> then </li>.

 

Then for your css

#nav a {
		 text-decoration: none;
}
#nav a img {
		border: none;
}
#nav ul {
	   display: inline;


}

 

That's only the very basics and presuming you don't want the default outline on the image and the nav to be horizontal.

 

Ask if you need more help, tell me if I haven't answered your question...

 

All the best :)

 

Sorry for late response - been away so will try this tonight. Is there a simple way of keeping the link in active state when on page?

 

Thanks B)

Couple of other options/variations:

 

1) Don't need a div to wrap all the navigation in, just give the ul an id="nav".

2) Use CSS for the background images, rather than have them in the HTML. Keeps you code cleaner and easier to maintain.

3) Use :hover on the anchor or list item in the CSS and specify a different image.

4) As for active state you'll either need to manually amend the page link by adding an id="active" or suchlike with some CSS; or try using PHP.

 

HTH?

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.