473,385 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Using separate divs for a navigation

17
Hi,

Okay so basically I have a navigation bar that consists of 5 clickable div links which are:

Home, About me, Portfolio, Experience and Contact

I am using 5 separate divs with image backgrounds because the font I have used isn't available in css. I seem to have a problem with when it comes to the styling of the links.

I have assigned;

a:hover and a:active to each div and used a different background image for both link states. So when the user hovers over the 'about me' div it displays a different image to the one it currently shows. However, the problem I'm having is that no matter what page I'm on, the images shown are the ones that relate to the "a:active". Now of course I cannot be on all five pages at the same time. Below I've placed a snippet of my code for you to look at. Any feedback would be much appreciated.

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. #home {
  4. background-image:url('../images/home.png');
  5. }
  6.  
  7. #home, a:hover {
  8. background-image:url('../images/home-hover-active.png');
  9. }
  10.  
  11. #home, a:active {
  12. background-image:url('../images/home-hover-active.png');
  13. }
  14.  
  15. #about-me {
  16. background-image:url('../images/about-me.png');
  17. }
  18.  
  19. #about-me, a:hover {
  20. background-image:url('../images/about-me-hover-active.png');
  21. }
  22.  
  23. #about-me, a:active {
  24. background-image:url('../images/about-me-hover-active.png');
  25. }
  26.  
Expand|Select|Wrap|Line Numbers
  1. <a href="./index.html">
  2.   <div id="home"></div>
  3. </a>
  4. <a href="./about-me.html">
  5.   <div id="about-me"></div>
  6. </a>
  7.  
Jun 17 '11 #1
4 2236
drhowarddrfine
7,435 Expert 4TB
Remove the comma after #home .
Jun 17 '11 #2
James
17
@drhowarddrfine
Did you mean the comma after every #home? tried that and it didn't work; it ended up not displaying the image I wanted when hovering and clicking
Jun 17 '11 #3
drhowarddrfine
7,435 Expert 4TB
Didn't look close enough. First, your html is invalid. You cannot wrap a block level element with an anchor which is inline. (However, this is now legal in HTML5.)
Jun 17 '11 #4
macem
8
drhowarddrfine is right, please use ul->li instead. I think that HTML5 is a mess, We should be copliant with XHTML then with HTML5 and we shouldn't wrap a block level element with an inline element.
Jun 21 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
7
by: Doug Thews | last post by:
I'm writing some sample threading code, and have already got many examples working that look a lot similar to the ones mentioned here. What I'm seeing is that most people put their method that...
3
by: Paul | last post by:
I found a great site for CSS tempaltes, http://blog.html.it/layoutgala/ . I downloaded them, and played around with them. Then I tried to use the template in as ASP.Net MasterPage, but everything...
0
by: Sam | last post by:
I am fairly new to ASP. Net 2.0, background MS Access 2000/2003 and working knowledge of SQL 2000. Scenario: Page1: Blank Page loads with 2 Text Boxes (TxtLast, TxtFirst), a Command...
3
by: atiq | last post by:
I have got serveral forms where i want to use the same command buttons for each form to navigate through records. i was wondering if there is a way of achieving this without having to create all of...
5
by: baskarpr | last post by:
Could somebody help me ? I have a left frame and right frame in a page. There is a form in right frame which has number of text box, checkbox, radio button, some static text's. For every input item...
16
by: ekokaos | last post by:
I have an image of an open book as the main menu on my website. Each word written in the book links to a related page. I would like to develop it further and have it so that the person can click a...
24
by: Chris F.A. Johnson | last post by:
On 2008-07-09, Denis McMahon wrote: If the left-hand column contains any text, use em rather than px to size it. In CSS, less is more. Most problems are caused by specifying too much rather...
5
by: LELE7 | last post by:
I'm new to PHP, but I usually program Windows Apps in .NET(c#, VB). So please excuse my unfamiliarity with code and HTML combined. It seems pretty simple to upload a file to a website using the...
5
by: jay patangan | last post by:
hi, gud day... i'm trying to write a program in javascript that uses .json. i already wrote one that is when i run the program, it will create a tab dynamically, using jquery, from my json data....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.