473,383 Members | 1,742 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,383 software developers and data experts.

how to change images when hovering

Hi!

Please be gentle; I'm new to ciwas and CSS in general, and know little
to no javascript (but that might win me points here ;-)

I have nine 'tab' images, with corresponding high-background versions
for display under hover, which I would like to control via CSS. When
on a page, the tab should be just an image rather than a link with
hover sensing, so that is probably easy to just use <img> rather than
<div> there.

My code looks like
#news
{
background-image : url("/images/news_off.gif") ;
width : 181 ; height : 20 ;
}
#news:hover
{
background-image : url("/images/news_on.gif") ;
width : 101 ; height : 20 ;
}
...
<div id='news'>&nbsp</div>
and that works for the moment. There's a lot I don't know, though.

1) What is the difference between .news and #news (and however else
I might define an element)?

2) I had to specify the sizes or the image was squished. Meanwhile,
this looks an awful lot like a table cell definition. Should I be
doing this as for an image (or a link)?

3) Do I have to repeat this (or whatever) code for all nine tabs or
is there a way to set up a generic style for the images and still
switch between _off and _on?

I would love to learn about CSS and so I would love pointers to good
tutorials. I'm in the middle of a project, though, and so meanwhile I
have a deadline and beg for your help :-)

Oh, yeah -- is there an email gateway for this newsgroup, not unlike
the perl-beginners list?
TIA & HAND

:-D
--
David T-G
Jul 20 '05 #1
1 14747
David T-G wrote:
I have nine 'tab' images, with corresponding high-background versions
for display under hover, which I would like to control via CSS. When
on a page, the tab should be just an image rather than a link with
hover sensing, so that is probably easy to just use <img> rather than
<div> there. My code looks like
#news
{
background-image : url("/images/news_off.gif") ;
width : 181 ; height : 20 ;
}
#news:hover
{
background-image : url("/images/news_on.gif") ;
width : 101 ; height : 20 ;
}
This is invalid. Your lengths require units. You should also note that MSIE
doesn't support :hover except on <a> elements.
...
<div id='news'>&nbsp</div>
and that works for the moment. There's a lot I don't know, though.
It won't work very well if the browser doesn't support, or has turned off,
images OR CSS.

You'd be better off using real text, with some image as the background. As
its a menu you should also consider not presenting it as a series of divs.
A menu is a list of links, so that's how you should present it.

http://www.maxdesign.com.au/presenta...rizontal07.htm would
probably be worth a look.
1) What is the difference between .news and #news (and however else
I might define an element)?
http://www.w3.org/TR/CSS2/selector.html#class-html
http://www.w3.org/TR/CSS2/selector.html#id-selectors

http://www.w3.org/TR/html4/struct/gl...tml#adef-class
http://www.w3.org/TR/html4/struct/global.html#adef-id
2) I had to specify the sizes or the image was squished.
I doubt it. More likely the image was masked. (The term squished suggests
scaling).
3) Do I have to repeat this (or whatever) code for all nine tabs or
is there a way to set up a generic style for the images and still
switch between _off and _on?
You would need JavaScript to avoid seperate definitions for each image.
Using real text with a common background image would work better IMO.
I would love to learn about CSS and so I would love pointers to good
tutorials.


http://dorward.me.uk/www/css/#tutorials

--
David Dorward http://dorward.me.uk/
Jul 20 '05 #2

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

Similar topics

1
by: Spike | last post by:
Hello! Im going to make a javascript for changing alot of images. But im not sure how to do it., where to start.. Ok, first.. this is the isue. I have 3 images(I call them 1a-3a). when u...
4
by: salty_dogs | last post by:
thanks to all who helped steer me away from 'slicing' photoshop images to positioning with css. new question: i have a web page that has a navbar, simple text links. each of these links will...
4
by: prubin | last post by:
Hello. I've noticed a neat kind of text detail box that comes up when you hover over the movie thumbnail images on http://www.netflix.com/ How does one go about coding for this? Sincerely,...
2
by: chris_culley | last post by:
Hi there, I've got a gif with (highly) irregular shapes (lots of jigsaw pieces) that I want to map so that each piece is a link... The pieces are currently just a frame drawing, but as they...
61
by: phil-news-nospam | last post by:
Why does SVG need a different tag than other images? IMHO, SVG should be implemented as an image type just like any other image type, allowing it to work with <img> tags, and ... here is the...
1
by: max | last post by:
hello (is this a css or a javascript question? or both?) when hovering, I can change the background (bg) color of a field (div), e.g. http://www.bep-zuerich.ch/hover4.htm with javascript I...
0
by: empire5 | last post by:
Products Legal Support p1 L1 p2 L2 What would I do in MenuExample.css to change the top horizontal menu so the text Product Legal and Support is always white...
4
by: Anna97 | last post by:
Hi, I guess I've built my site sort of strangely: The images are in the html (using tables), but the text is all in css positioned using coordinates (hovering over the images). I need my page...
7
mikek12004
by: mikek12004 | last post by:
I want in all my scrolling divs to remove the scroll bar-quite easy through css, so now how to scroll the contents? After some searching I have found the following code which works perfectly ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.