tags:

views:

55

answers:

3

Hello everyone. I am using an image button for navigation, because I want hover effects. I mean, I used button image instead of <ul> tag or <div> tag because I want hover effects, meaning when I hover on that image the image changes. That's why I use image button.

But, I do not want to use images. I want to use <ul> tag and <div> tag but I am not familiar with how to do hover effect on those tags.

Please help me.

+1  A: 

All modern browsers can render :hover CSS selector on every element. You just have to change background-image properties for your <ul> tags then.

But there are many possibilities with javascript, jquery and so on, which will enable you to use it in every browser.

Tom
thanks alot Tom
Ricky Dang
A: 

Not sure if I understand but if I do it's this:

ul:hover
{
background-color: #f00;
}

or

div:hover
{
background-color: #f00;
}

About as good an answer I can give considering the question.

Kyle Sevenoaks
+1  A: 

You need to use CSS to do this. If you wish to have a list of buttons, then I strongly suggest you use a ul parent element and then li child elements. Don't use divs inside the ul.

<ul>
    <li id='button1'>Button 1</li>
    <li id='button2'>Button 2</li>
</ul>

#button1 {background-image: url(IMAGE PATH GOES HERE)}
#button1:hover {background-image: url(HOVER IMAGE PATH GOES HERE)}

The CSS property background-image places whatever image you specify in IMAGE PATH GOES HERE as the background for that element. The :hover pseudo-selector allows you to alter an image when the user hovers it with their mouse. In this case, we are providing a different image path effectively altering the image when the li is hovered.

In case you are not familiar with CSS, you can learn more about it here.

Rupert
@rupert Thanks for this answer but i do not want to use images...in that case how can i implement this code...
Ricky Dang
@giteshdang What effect are you trying to create on the hover? Essentially, you just need to change background-image to whatever property you are trying to alter. I can't tell you which one without knowing what effect you are trying to create. If you tell me the effect I will try and point you in the right direction.
Rupert
@rupert actualy in some web sites when we hover the pointer on the navigation button there is a change on the background of button..i want to know that is that image or div..???
Ricky Dang
What is the button? Is it a button tag or a div tag? If it is a div tag then the image is being added to the button via CSS and then being changed using :hover, just as in my example. Post a link to an example.
Rupert
Thanks Rupert...thanks a lot..i understand now....
Ricky Dang