Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-29-2005, 12:32 PM   PM User | #1
mark87
Senior Coder

 
Join Date: Dec 2004
Location: Essex, UK
Posts: 2,636
Thanks: 0
Thanked 0 Times in 0 Posts
mark87 is on a distinguished road
Image Size on Hover

Is there a way to change an image size when a link of an image is hovered over? I can't seem to work it out...
mark87 is offline   Reply With Quote
Old 05-29-2005, 01:23 PM   PM User | #2
mrruben5
Regular Coder

 
Join Date: Nov 2004
Location: The Netherlands
Posts: 551
Thanks: 0
Thanked 0 Times in 0 Posts
mrruben5 is an unknown quantity at this point
Yes this is possible. You can do this with javascript or css.

javascript:

onmouseover="this.size=x" onmouseout="this.size=x" or something like that.

css:

a:hover img#id {width: 300px;}, where #id=is the idd of the image.

I don't know if both ways work though, not tried.
__________________
CATdude about IE6: "All your box-model are belong to us"
mrruben5 is offline   Reply With Quote
Old 05-29-2005, 01:30 PM   PM User | #3
mark87
Senior Coder

 
Join Date: Dec 2004
Location: Essex, UK
Posts: 2,636
Thanks: 0
Thanked 0 Times in 0 Posts
mark87 is on a distinguished road
Thanks, only tried the CSS method but can't seem to get it to work - here's what I have if you can see where I'm going wrong -

CSS -

a:link img#im {
width: 60px;
height: 65px;
border: 10px solid #0000FF;
}

a:hover img#im {
width: 80px;
height: 85px;
border: 1px solid #0000FF;
}

HTML -

<ul>
<li><a href="#"><img id="im" src="image1.jpg"></a></li>
<li><a href="#"><img id="im" src="image2.jpg"></a></li>
<li><a href="#"><img id="im" src="image3.jpg"></a></li>
<li><a href="#"><img id="im" src="image4.jpg"></a></li>
<li><a href="#"><img id="im" src="image5.jpg"></a></li>
</ul>

I'm guessing where it's not working is the fact each image has the same ID... but this is for a menu where I want each image to get larger on hover.
mark87 is offline   Reply With Quote
Old 05-29-2005, 02:02 PM   PM User | #4
Bill Posters
Senior Coder

 
Join Date: Feb 2003
Posts: 1,665
Thanks: 0
Thanked 27 Times in 25 Posts
Bill Posters will become famous soon enough
e.g.
Code:
ul, li {
list-style: none;
}

ul#im a:link img {
width: 60px;
height: 65px;
border: 10px solid #0000FF;
}

ul#im a:hover img {
width: 78px;
height: 83px;
border: 1px solid #0000FF;
}
Code:
<ul id="im">
	<li><a href="…"><img src="image1.jpg" width="60" height="65" alt="…"></a></li>
	<li><a href="…"><img src="image2.jpg" width="60" height="65" alt="…"></a></li>
	<li><a href="…"><img src="image3.jpg" width="60" height="65" alt="…"></a></li>
	<li><a href="…"><img src="image4.jpg" width="60" height="65" alt="…"></a></li>
	<li><a href="…"><img src="image5.jpg" width="60" height="65" alt="…"></a></li>
</ul>
Bill Posters is offline   Reply With Quote
Old 05-29-2005, 02:18 PM   PM User | #5
mark87
Senior Coder

 
Join Date: Dec 2004
Location: Essex, UK
Posts: 2,636
Thanks: 0
Thanked 0 Times in 0 Posts
mark87 is on a distinguished road
Thanks, still can't get it working though, and I copied your example exactly to make sure I was doing it right...
mark87 is offline   Reply With Quote
Old 05-29-2005, 03:53 PM   PM User | #6
harbingerOTV
Senior Coder

 
Join Date: Jan 2005
Location: Memphis, TN
Posts: 1,765
Thanks: 8
Thanked 123 Times in 121 Posts
harbingerOTV will become famous soon enough
try this

IE6 and Mozilla likes it.


I'll assume it was IE giving you a hard time as mozilla liked Bills' code well enough.
harbingerOTV is offline   Reply With Quote
Old 05-30-2005, 08:48 AM   PM User | #7
jadusoft.com
New to the CF scene

 
Join Date: May 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
jadusoft.com is an unknown quantity at this point
you will get pre made code at http://www.dynamicdrive.com
__________________
JaduSoft.com - Start your own live support, stats, payment, anonymous services.
Best software Products in affordable price.
jadusoft.com is offline   Reply With Quote
Old 05-30-2005, 11:10 AM   PM User | #8
mrruben5
Regular Coder

 
Join Date: Nov 2004
Location: The Netherlands
Posts: 551
Thanks: 0
Thanked 0 Times in 0 Posts
mrruben5 is an unknown quantity at this point
Off course! A background image! That always helps, but you can't scale the image then. And that's what he's trying to acomplish.
__________________
CATdude about IE6: "All your box-model are belong to us"
mrruben5 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:20 PM.


Advertisement
Log in to turn off these ads.