HighDots Forums  

Highlighting a table row during hover

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Highlighting a table row during hover in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
R
 
Posts: n/a

Default Highlighting a table row during hover - 11-06-2009 , 10:25 AM






Folks,
I've seen it done (though cannot find an example at the moment) - I
want a table row background colour to change when any one cell within
the row has the mouse pointer hovering over it.

Example

<table>
<tr><td>alpha</td><td>apple</td></tr>
<tr><td>bravo</td><td>banana</td></tr>
</table>

If I were to hover the mouse over alpha, I would want the background
colour to alpha and apple to change...

I appreciate the help...

Reply With Quote
  #2  
Old   
Gordon
 
Posts: n/a

Default Re: Highlighting a table row during hover - 11-06-2009 , 11:05 AM






On Nov 6, 3:25*pm, R <fiprojects.... (AT) gmail (DOT) com> wrote:
Quote:
Folks,
I've seen it done (though cannot find an example at the moment) - I
want a table row background colour to change when any one cell within
the row has the mouse pointer hovering over it.

Example

table
tr><td>alpha</td><td>apple</td></tr
tr><td>bravo</td><td>banana</td></tr
/table

If I were to hover the mouse over alpha, I would want the background
colour to alpha and apple to change...

I appreciate the help...
tr:hover in your CSS is how to do it. This, uncurprisingly, won't
work in IE6. If you need it to work in IE6 as well then you will need
to investigate a Javascript solution

Reply With Quote
  #3  
Old   
Kevin Nathan
 
Posts: n/a

Default Re: Highlighting a table row during hover - 11-06-2009 , 11:11 AM



On Fri, 6 Nov 2009 07:25:06 -0800 (PST)
R <fiprojects.com (AT) gmail (DOT) com> wrote:

Quote:
Folks,
I've seen it done (though cannot find an example at the moment) - I
want a table row background colour to change when any one cell within
the row has the mouse pointer hovering over it.

Put the onmouseover and onmouseout events in the TR tag:

<tr onmouseover="className='class1'" onmouseout="className='class2'">

We use two alternating colors for the background and a third for the
highlight on rollover, so it is more complicated, but that should work
for just highlighting... :-)


--
Kevin Nathan (Arizona, USA)
Linux Potpourri and a.o.l.s. FAQ -- (temporarily offline)

Open standards. Open source. Open minds.
The command line is the front line.
Linux 2.6.25.20-0.5-pae
9:06am up 15 days 23:19, 38 users, load average: 0.15, 0.26, 0.44

Reply With Quote
  #4  
Old   
Andreas Prilop
 
Posts: n/a

Default Re: Highlighting a table row during hover - 11-06-2009 , 11:13 AM



On Fri, 6 Nov 2009, R wrote:

Quote:
I want a table row background colour to change when any one cell
within the row has the mouse pointer hovering over it.
tr:hover td { background: yellow }

--
In memoriam Alan J. Flavell
http://groups.google.co.uk/groups/search?q=author:Alan.J.Flavell

Reply With Quote
  #5  
Old   
R
 
Posts: n/a

Default Re: Highlighting a table row during hover - 11-09-2009 , 05:51 PM



Thanks all!

Greatly apprecaited... hadn't thought of setting the class in the <tr>
tag! Silly me! And the onmouse event too is a solution that escaped me
though my intranet based application will be firefox based, its
something I will keep in mind!

Reply With Quote
  #6  
Old   
Jim Moe
 
Posts: n/a

Default Re: Highlighting a table row during hover - 11-10-2009 , 12:47 PM



On 11/06/09 09:13 am, Andreas Prilop wrote:
Quote:
On Fri, 6 Nov 2009, R wrote:

I want a table row background colour to change when any one cell
within the row has the mouse pointer hovering over it.

tr:hover td { background: yellow }

:hover does not work for IE version 6 and earlier. The only element
where hover was implemented was <a>. Most people have Javascript enabled
so using a onmouseover() event can compensate for IE6.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)

Reply With Quote
  #7  
Old   
Gordon
 
Posts: n/a

Default Re: Highlighting a table row during hover - 11-11-2009 , 04:20 AM



On Nov 10, 5:47*pm, Jim Moe <jmm-list.AXSPA... (AT) sohnen-moe (DOT) com> wrote:
Quote:
On 11/06/09 09:13 am, Andreas Prilop wrote:> On Fri, 6 Nov 2009, R wrote:
* :hover does not work for IE version 6 and earlier. The only element
where hover was implemented was <a>. Most people have Javascript enabled
so using a onmouseover() event can compensate for IE6.
As CSS provides a mechanism for doing this, I'd tend to prefer the CSS
method. It's not CSS's fault that IE6 doesn't implement it
properly. Besides, the more javascript you have on a page the
worse it performs.

If it absolutely must work on IE6, I'd include a javascript for doing
it with the conditional comment mechanism. That way everyone else can
use the CSS approach and only IE6 users get the javascript that nobody
else needs

Reply With Quote
Reply




Thread Tools
Display Modes

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

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.