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

CSS background images not filling the cell

I'm kind of new to CSS and hope someone knows how to fix a problem
I've been fighting with for days.

I'm trying to create a mouseover navbar with CSS which inserts a
colored background JPG that fills a transparent cell using "a:hover"
and inserts a different colored JPG after you click on the link and
are on the linked page ("a:active" I assume).

My current test works fine (at least on the "a:hover" part) but the
background won't fill the cell, no matter what I do. When I create a
class and apply it to an ordinary cell, the background jpg fills the
cell with no trouble. But as soon as I try to do the same thing with
links, the background jpg won't fill the cell.

I only want certain, specified links to work this way, not every link
on the page. I haven't created any linked documents yet to test out
the "a:active" part of the navbar. I hope it will work?? The style
sheet needs to be external due to the number of pages I'm going to
have to "upgrade" if I can get this to work.

Your suggestions will be HUGELY appreciated!

========================
MY EXTERNAL STYLE SHEET
========================
..mouseovertest a:link, a:visited {
color: 003366;
font-family: arial;
font-size: 10px;
text-decoration: none;
}

..mouseovertest a:hover {
color: 3399CC;
background: url(../Media/colorchange.jpg);
}

..mouseovertest a:active {
color: 003366;
background: url(../Media/colorchange2.jpg);
}

====================
MY TEST HTML PAGE
====================
<html>
<head>
<meta http-equiv="content-type"
content="text/html;charset=iso-8859-1">
<title>Mouseover test</title>
<link rel="stylesheet" href="../NewFiles/mouseovertest.css"
type="text/css">
</head>
<body>
<table border="1" cellpadding="8">
<tr>
<td class="mouseovertest"><a href="#">Mouseover</a></td>
<td class="mouseovertest"><a href="#">Mouseover</a></td>
<td class="mouseovertest"><a href="#">Mouseover</a></td>
</tr>
</table>
</body>
</html>
Jul 20 '05 #1
1 6742
dh*****@abrasive-tech.com (dhunter) wrote:
I'm trying to create a mouseover navbar with CSS which inserts a
colored background JPG that fills a transparent cell using "a:hover"
and inserts a different colored JPG after you click on the link and
are on the linked page ("a:active" I assume).
a:visited actually. a:active applies to the current active link (i.e.
the one in the process of being activated) once the next page has
loaded there is no active link until the user clicks on one, but the
link to the current page (bad practice - pages shouldn't link to
themselves) will obviously be visited.
My current test works fine (at least on the "a:hover" part) but the
background won't fill the cell, no matter what I do. When I create a
class and apply it to an ordinary cell, the background jpg fills the
cell with no trouble. But as soon as I try to do the same thing with
links, the background jpg won't fill the cell. .mouseovertest a:link, a:visited {
color: 003366;
font-family: arial;
font-size: 10px;
text-decoration: none;
}

.mouseovertest a:hover {
color: 3399CC;
background: url(../Media/colorchange.jpg);
}

.mouseovertest a:active {
color: 003366;
background: url(../Media/colorchange2.jpg);
}
That sets the background image on the <a> element, not the <td>
element. If you want to make the <a> element fill the cell then set

..mouseovertest a {display: block;}
<table border="1" cellpadding="8">
<tr>
<td class="mouseovertest"><a href="#">Mouseover</a></td>
<td class="mouseovertest"><a href="#">Mouseover</a></td>
<td class="mouseovertest"><a href="#">Mouseover</a></td>
</tr>
</table>


It would be less work to have the class on the table rather than on
every cell. And are you sure that this is a table?

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #2

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

Similar topics

1
by: Justin | last post by:
Ok here is working code in IE, <td ID="TD1" width="478" height="553" background="images/GUYONDOC.JPG" valign="top">. . . </td> <a href="texana.htm"...
3
by: veryred | last post by:
Hello. I'm placing a background image in a table cell using a style sheet--I reads it, Netscape, Firefox, and Opera do not--they will however read background-color when I insert that. This is...
21
by: Dan V. | last post by:
I have tried a number of things including preloading, but the background image (water tile in header) in IE 6 will not display where other browsers will....
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
5
by: Derek Fountain | last post by:
I have a horizontal navigation bar, which is a single row table containing the right images. It "stretches" itself across the screen using a penultimate td like this: <td width="100%"...
5
by: proximus | last post by:
Hi, I am trying to change the background of table TD's. The problem is that I have no access to the HTML code. SO I am trying to alter this using Javascript/DOM in an external .js file. I...
5
by: Michael | last post by:
Is there a way to specify a background-image for a html table cell in a theme's css file. I know a lot of things I can't do... can't figure out one that I can do: 1) ~/ Images/logo.gif...
2
by: Jim | last post by:
How can I use JavaScript to change a background image in a table cell? Here's the code for the cell <td width="338" valign="top" background="../images/ LEC_Q1.jpg"><div...
5
denny1824
by: denny1824 | last post by:
I want each cell in a table on the Master page to have its own background image. The images exist, but none of them show on the page. <body> <form id="form1" runat="server"> <table...
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: 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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.