Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
mouseover background change.
Old 02-01-2008, 07:55 AM mouseover background change.
vkw91's Avatar
Ultra Talker

Latest Blog Post:
Good Web Design Guide - part 1
Posts: 314
Name: Vicky
Location: Wales
Trades: 0
What is the best way to have a mouse over on a div tag so that when the mouse is placed over the area, the background image of the div changes??

CSS please, i don't really what to use javascript?
__________________
Blog (new):
Please login or register to view this content. Registration is FREE

Portfolio:
Please login or register to view this content. Registration is FREE

Techno Pup:
Please login or register to view this content. Registration is FREE

vkw91 is offline
Reply With Quote
View Public Profile Visit vkw91's homepage!
 
 
Register now for full access!
Old 02-01-2008, 01:44 PM Re: mouseover background change.
Mooofasa's Avatar
Defies a Status

Posts: 1,611
Name: Michael (mik) Land
Location: England
Trades: 0
Code:
div#selector:hover{...}
But it won't work in non-supporting browsers, such as Internet Explorer.

The other method (I am not keen on this one)
HTML Code:
<a href=""><div>...</div></a>
Code:
a:hover div{...}
__________________

Please login or register to view this content. Registration is FREE
- Tumblog with thoughts, quotes, links, videos, images and my creations.

Please login or register to view this content. Registration is FREE
- The best free web browser.

Please login or register to view this content. Registration is FREE
- Firefox is now Firefail.
Mooofasa is offline
Reply With Quote
View Public Profile Visit Mooofasa's homepage!
 
Old 02-01-2008, 02:30 PM Re: mouseover background change.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
<div>s are block elements and cannot be enclosed by inline elements such as <a>nchors.

if you want it to work in IE6 and below you'll need this http://www.xs4all.nl/~peterned/csshover.html

and just add a :hover pseudo class to the element.

However, changing backgrounds on mouseover or hover can be a rather "clunky" operation.
Changing the classname of the element with javascript is a much cleaner method and only needs
HTML Code:
onmouseover="this.className='newClass'" onmouseout="this.className='oldClass'"
adding to the open tag
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-01-2008, 02:36 PM Re: mouseover background change.
Mooofasa's Avatar
Defies a Status

Posts: 1,611
Name: Michael (mik) Land
Location: England
Trades: 0
Yes they can. However, it is not semantic. You must weigh that up with the possibility of some loosing the feature because they have Javascript disabled (though that would be a significantly small proportion).
__________________

Please login or register to view this content. Registration is FREE
- Tumblog with thoughts, quotes, links, videos, images and my creations.

Please login or register to view this content. Registration is FREE
- The best free web browser.

Please login or register to view this content. Registration is FREE
- Firefox is now Firefail.

Last edited by Mooofasa; 02-01-2008 at 02:37 PM..
Mooofasa is offline
Reply With Quote
View Public Profile Visit Mooofasa's homepage!
 
Old 02-01-2008, 02:59 PM Re: mouseover background change.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Yep, they can. You can do anything you want in HTML should you really want to. Provided you are not bothered whether it works in all user agents or not.

Maybe I should have worded it to "and should not be enclosed". But generally we try to teach the correct way to code in HTML, irrespective of validation to a particular doctype. And a block (structural) element inside inline or markup elements has been poor code since HTML 1.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-01-2008, 03:01 PM Re: mouseover background change.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
BTW,
Apologies if the above post sounds patronising, it wasn't meant to be.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-01-2008, 03:12 PM Re: mouseover background change.
Mooofasa's Avatar
Defies a Status

Posts: 1,611
Name: Michael (mik) Land
Location: England
Trades: 0
It wasn't patronising.

The war within Web standards: pragmatists versus purists
__________________

Please login or register to view this content. Registration is FREE
- Tumblog with thoughts, quotes, links, videos, images and my creations.

Please login or register to view this content. Registration is FREE
- The best free web browser.

Please login or register to view this content. Registration is FREE
- Firefox is now Firefail.
Mooofasa is offline
Reply With Quote
View Public Profile Visit Mooofasa's homepage!
 
Reply     « Reply to mouseover background change.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 2.88069 seconds with 12 queries