Jump to content

CSS background not changine on :active


cs.punk

Recommended Posts

Anyone know why?

 

        ul#menu {
width: 528px; margin: 0px auto;
list-style: none;
}

ul#menu li { display: inline; }

ul#menu li a {
display: block; float: left; height: 60px;
background-image: url(/nav.jpg); text-indent: -5000px;
}

ul#menu li a.home {
width: 132px; background-position: 0 0;	
}

ul#menu li a.home:hover {
width: 132px; background-position: 0 -60px;	
}

ul#menu li a.home:active {
width: 132px; background-position: 0 -120px;	
}

 

<div class='menu-bar'>
<ul id="menu">
<li><a href="/index.php" class="home">Home</a></li>
</ul>
</div>

 

CSS isn't really my specialty so any help would be appreciated. :)

Link to comment
Share on other sites

if i remember correctly, the pseudo-class of ':active' only has an affect after the time the user clicks a link to the time it takes to show the new page.

 

keeping this in mind, is it possible that the :active class is working but your internet connection is loading the page too fast for you to see the change?

 

to check this, instead of left clicking on the link, hold the left click down and see if the background then changes

Link to comment
Share on other sites

You had two extra curly brackets within your CSS code, below is the working code:

 

<style type="text/css"> 
ul#menu {
width: 528px; margin: 0px auto;
list-style: none;
}

ul#menu li { display: inline; }

ul#menu li a {
display: block; float: left; height: 60px;
background-image: url(/nav.jpg);
text-indent: -5000px;
}

ul#menu li a.home {
width: 132px; background-position: 0 0;	
}

ul#menu li a.jokes {
width: 132px; background-position: -132px 0;	
}

ul#menu li a.games {
width: 132px; background-position: -264px 0;	
}

ul#menu li a.random {
width: 132px; background-position: -396px 0;	

}

ul#menu li a.home:hover {
width: 132px; background-position: 0 -60px;	
}

ul#menu li a.home:active {
width: 132px; background-position: 0 -120px;	
}
</style> 

 

best regards

 

 

EDIT:

infact, the code you origionally posted was correct, its the CSS code on your site which has the extra curly brackets.

Link to comment
Share on other sites

You had two extra curly brackets within your CSS code, below is the working code:

 

<style type="text/css"> 
ul#menu {
width: 528px; margin: 0px auto;
list-style: none;
}

ul#menu li { display: inline; }

ul#menu li a {
display: block; float: left; height: 60px;
background-image: url(/nav.jpg);
text-indent: -5000px;
}

ul#menu li a.home {
width: 132px; background-position: 0 0;	
}

ul#menu li a.jokes {
width: 132px; background-position: -132px 0;	
}

ul#menu li a.games {
width: 132px; background-position: -264px 0;	
}

ul#menu li a.random {
width: 132px; background-position: -396px 0;	

}

ul#menu li a.home:hover {
width: 132px; background-position: 0 -60px;	
}

ul#menu li a.home:active {
width: 132px; background-position: 0 -120px;	
}
</style> 

 

best regards

 

 

EDIT:

infact, the code you origionally posted was correct, its the CSS code on your site which has the extra curly brackets.

 

Ah I see what happened my original problem was the two extra curly braces, but when i copied my source to here i removed some other stuff and in the process cleaned it up :). Thanks for you help man.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.