473,387 Members | 2,436 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,387 software developers and data experts.

Make a div with image a:hover?

Hi,

I am wondering if someone could guide me in the right direction about
this. How can I make div 'one' hover? Does not need to be
clickable/link...It would be easy if the images was not there..But now
it is..

<div class="one"><img src="img/someimage.gif" alt="" /><a
href="index.php">Text bla bla bla</a></div>

I know that I have to do something like:

..one a {
display: block;
width: 200px;
height: 40px;
background-color: #f1f1f1;
padding: 5px;
}

..one a:hover {
display: block;
width: 200px;
height: 40px;
background-color: #ccccc;
padding: 5px;
}

Anyone know how?

Greetings and thanks from Gnolen
Jul 21 '05 #1
3 8206
In article <11*******************@newsb.telia.net>, he***********@hotmail.com
enlightened us with...
I am wondering if someone could guide me in the right direction about
this. How can I make div 'one' hover?


I don't think that's supported until CSS2, but don't quote me.

I know you can do this with javascript.
<div class="one" onMouseOver="someFunction()" onMouseOut="someOtherFunction
()">

--
--
~kaeli~
Suicide is the most sincere form of self-criticism.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 21 '05 #2
Gnolen wrote:
Hi,

I am wondering if someone could guide me in the right direction about
this. How can I make div 'one' hover? Does not need to be
clickable/link...It would be easy if the images was not there..But now
it is..

<div class="one"><img src="img/someimage.gif" alt="" /><a
href="index.php">Text bla bla bla</a></div>

I know that I have to do something like:

.one a {
display: block;
width: 200px;
height: 40px;
background-color: #f1f1f1;
padding: 5px;
}

.one a:hover {
display: block;
width: 200px;
height: 40px;
background-color: #ccccc;
padding: 5px;
}

Anyone know how?

Greetings and thanks from Gnolen

IE only supports :hover on anchors with a href.
(think Gecko supports :hover on many more elements)
make the a 'display: block' and remove the div.
of course, in the hover you only add what changes.
if you really want you can put the image in the background.

a.one {
display: block;
width: 200px;
height: 40px;
padding: 5px;
background-color: #eee;
background-image: url(img/someimage.gif);
background-repeat: no-repeat;
}

a.one:hover {
background-color: #ccc;
}

<a class="one" href="index.php">Text bla bla bla</a>
gl
martin
Jul 21 '05 #3
to make sure your text will appear below to the image you can ajust the
padding

a.one {
padding: 45px 5px 5px 5px;
}

this will make your a-block 45+40+5 px high (in standard mode)
unless you add so much text that it doesnt fit, in that case IE will
stretch your a-block , and in gecko it will appear growing outside the
a-block
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Chris Beall | last post by:
I'm displaying an image that is also a link against a black background. In Netscape 7.1, the current background color is displayed as a horizontal bar below the image. This allows :hover effects...
8
by: JLahm | last post by:
I have defined a class for my images called .image that specifies the default border color, width and style. I'd like to be able to have the pseudo elements link, visited and active have one color...
2
by: Elisa | last post by:
I have two images, each with defined CSS hover states. I would like a mouseover on one image to trigger the hover state of the other image. Is this possible using javascript? If so, how? Any...
1
by: NH | last post by:
Ok, I need to figure out the best way to create an image with a hyperlink with in. I have a gridview which lists peoples names, I want to put in a column that displays each persons summary data...
7
by: fredo | last post by:
I've studied Eric Meyer's pure css popups, version two: http://meyerweb.com/eric/css/edge/popups/demo2.html which pops up an image when I roll over a text link. Now I want to pop up a large...
2
by: Riverburn | last post by:
I've got a question regarding making menu's in Css. I've made a picture of the menu in photoshop, have made the mouseover effect in different frames, and made a quick pregenerated html/javascript...
1
by: nicky77 | last post by:
Hi, I've created a nav bar using a background image for rollover effects. Everything works as I had hoped, however, for some reason it seems that an area of whitespace (the same size of the...
8
by: Haines Brown | last post by:
I want a hot text string to display an image only when hovered. In the body: .... <a id="link-a" href="#nogo"> <img id="photo" src="..." />hot text </a> ....
16
by: stevedude | last post by:
CSS newbie again. I have a problem trying to get coffee mug images within anchor tags to center with my link text for a vertical list menu. If I use the horizontal/vertical properties of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.