Solved

CSS Menu with Table Cell Rollover

Posted on 2006-06-15
9
224 Views
Last Modified: 2008-02-01
Is there a way to have a table cell highlight with color change where the cell contains a background image?

I have a table cell that uses a background image, when the mouse moves over the table cell changes color, but I don't know how to set the onMouseOut to nothing. So that the table cell appears as it did before the mouseover.

Hope this makes some kind of sense.

Thanks
0
Comment
Question by:greddin
  • 5
  • 2
9 Comments
 
LVL 10

Expert Comment

by:jagadeesh_motamarri
ID: 16917468
... are u using css for  >> I have a table cell that uses a background image, when the mouse moves over the table cell changes color.

If so can u please post the code so that it will be easy to make necessary chances.

...one suggestion is u can take an id for that celll and use the hover effect on the particular cell.

_____Jags.
0
 
LVL 10

Expert Comment

by:jagadeesh_motamarri
ID: 16917508
or else you simply use somthing like this

<tr style="background-color:'#D2D8F9'"  onmouseover="this.runtimeStyle.cssText='background-color:#FFCC66'" onmouseout="this.runtimeStyle.cssText=''" >


_____Jags.
0
 

Author Comment

by:greddin
ID: 16917515
Sure, here's what I have right now.

function ss_navBar( tableCellRef, hoverFlag, navStyle, strTextColor, strHoverTextColor, strHoverBackgroundColor, strBackgroundColor ) {
      if ( hoverFlag ) {
                      switch ( navStyle ) {
                  case 1:
                        tableCellRef.style.color = strHoverTextColor;
                        tableCellRef.style.backgroundColor = strHoverBackgroundColor;
                        tableCellRef.style.cursor = 'hand';
                        break;
                  default:
                        if ( document.getElementsByTagName ) {
                              tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#CCCCCC';
                              tableCellRef.getElementsByTagName( 'a' )[0].style.cursor = 'hand';
                        }
            }
      } else {
            switch ( navStyle ) {
                  case 1:
                        tableCellRef.style.color = strTextColor;
                        tableCellRef.style.backgroundColor = strBackgroundColor;
                        tableCellRef.style.cursor = 'hand';
                        break;
                  default:
                        if ( document.getElementsByTagName ) {
                              tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#CCCCCC';
                              tableCellRef.getElementsByTagName( 'a' )[0].style.cursor = 'hand';
                        }
            }
      }
}

function ss_goTo( url ) {
      window.location.href = url;
}

function ss_navBarClick( tableCellRef, navStyle, url ) {
      ss_navBar( tableCellRef, 0, navStyle );
      ss_goTo( url );
}


<table width='100%' cellspacing=0 cellpadding=0 border=1 style='color:#000000; background-image:url("/stellent/groups/public/documents/cnic_hq_image/cnic_gradient_bg.gif");  background-color:#ffffff;'>
<tr>
<td nowrap align=center style="padding:2px; font-family:verdana; font-style:normal; font-size:10px; font-weight:normal; color:#000000;" onmouseover=ss_navBar(this,1,1,'#000000','#cccccc','#eeeeee','#ffffff'); onclick=ss_navBarClick(this,1,'/cnic_hq_site/AboutCNIC/index.htm') onmouseout=ss_navBar(this,0,1,'#000000','#cccccc','#eeeeee','#ffffff')>About CNIC</td>
<td style="color:#000000;font-family:verdana;font-size:8pt;text-align:center;vertical-align:middle;white-space:nowrap;padding-top:1px;padding-bottom:1px;padding-left:1px;padding-right:1px;height:19px;">|</td>
<td nowrap align=center style="padding:2px; font-family:verdana; font-style:normal; font-size:10px; font-weight:normal; color:#000000;" onmouseover=ss_navBar(this,1,1,'#000000','#cccccc','#eeeeee','#ffffff'); onclick=ss_navBarClick(this,1,'/cnic_hq_site/Regions/index.htm') onmouseout=ss_navBar(this,0,1,'#000000','#cccccc','#eeeeee','#ffffff')>Regions</td>
<td style="color:#000000;font-family:verdana;font-size:8pt;text-align:center;vertical-align:middle;white-space:nowrap;padding-top:1px;padding-bottom:1px;padding-left:1px;padding-right:1px;height:19px;">|</td>
<td nowrap align=center style="padding:2px; font-family:verdana; font-style:normal; font-size:10px; font-weight:normal; color:#000000;" onmouseover=ss_navBar(this,1,1,'#000000','#cccccc','#eeeeee','#ffffff'); onclick=ss_navBarClick(this,1,'/cnic_hq_site/Library/index.htm') onmouseout=ss_navBar(this,0,1,'#000000','#cccccc','#eeeeee','#ffffff')>Library</td>
<td style="color:#000000;font-family:verdana;font-size:8pt;text-align:center;vertical-align:middle;white-space:nowrap;padding-top:1px;padding-bottom:1px;padding-left:1px;padding-right:1px;height:19px;">|</td>
<td nowrap align=center style="padding:2px; font-family:verdana; font-style:normal; font-size:10px; font-weight:normal; color:#000000;" onmouseover=ss_navBar(this,1,1,'#000000','#cccccc','#eeeeee','#ffffff'); onclick=ss_navBarClick(this,1,'/cnic_hq_site/CNICJobs/index.htm') onmouseout=ss_navBar(this,0,1,'#000000','#cccccc','#eeeeee','#ffffff')>CNIC Jobs</td>
<td style="color:#000000;font-family:verdana;font-size:8pt;text-align:center;vertical-align:middle;white-space:nowrap;padding-top:1px;padding-bottom:1px;padding-left:1px;padding-right:1px;height:19px;">|</td>
<td nowrap align=center style="padding:2px; font-family:verdana; font-style:normal; font-size:10px; font-weight:normal; color:#000000;" onmouseover=ss_navBar(this,1,1,'#000000','#cccccc','#eeeeee','#ffffff'); onclick=ss_navBarClick(this,1,'/cnic_hq_site/CompetitiveSourcing/index.htm') onmouseout=ss_navBar(this,0,1,'#000000','#cccccc','#eeeeee','#ffffff')>Competitive Sourcing</td>
<td style="color:#000000;font-family:verdana;font-size:8pt;text-align:center;vertical-align:middle;white-space:nowrap;padding-top:1px;padding-bottom:1px;padding-left:1px;padding-right:1px;height:19px;">|</td>
<td nowrap align=center style="padding:2px; font-family:verdana; font-style:normal; font-size:10px; font-weight:normal; color:#000000;" onmouseover=ss_navBar(this,1,1,'#000000','#cccccc','#eeeeee','#ffffff'); onclick=ss_navBarClick(this,1,'/cnic_hq_site/BRAC/index.htm') onmouseout=ss_navBar(this,0,1,'#000000','#cccccc','#eeeeee','#ffffff')>BRAC</td>
</tr>
</table>
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Expert Comment

by:jagadeesh_motamarri
ID: 16917530
...did u try my other solution
0
 

Author Comment

by:greddin
ID: 16917540
Yes, it didn't error, but it also didn't work either. Thank you.
0
 
LVL 10

Expert Comment

by:jagadeesh_motamarri
ID: 16917590
Oh ...sorry about that code. Check out this -

CODE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>




<table width="100" border="1">
  <tr>
    <td style=" background-color:#FF0000" onmouseover="this.style.backgroundColor='blue'" onmouseout="this.style.backgroundColor='red'">asdfasdfasjdfasjdl;f</td>
    <td>asdfasdfasjdfasjdl;f</td>
  </tr>
  <tr>
    <td>asdfasdfasjdfasjdl;f</td>
    <td>asdfasdfasjdfasjdl;f</td>
  </tr>
  <tr>
    <td>asdfasdfasjdfasjdl;f</td>
    <td>asdfasdfasjdfasjdl;f</td>
  </tr>
</table>

</body>
</html>

------try changing yours accordingly


_____Jags.
0
 
LVL 10

Accepted Solution

by:
jagadeesh_motamarri earned 500 total points
ID: 16920885
Hi greddin,

wanna include css seperately -

herez the code - http://www.experts-exchange.com/Web/Web_Languages/CSS/Q_20943924.html

<html>
<head>
<style>
.classover {background-color: #ff0000;}
</style>
</head>

<body>
<table>
<tr>
   <td  onmouseover="this.className='classover'" onmouseout="this.className=''">aaa</td>
   <td  onmouseover="this.className='classover'" onmouseout="this.className=''">aaa</td>
</tr>
<tr>
   <td  onmouseover="this.className='classover'" onmouseout="this.className=''">aaa</td>
   <td  onmouseover="this.className='classover'" onmouseout="this.className=''">aaa</td>
</tr>
</table>

</body>
</html>

_______Jags.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
can't display bootstrap glyphs in select menu 4 33
Syntax Error 2 47
WordPress Themes 10 34
Problem with a CSS in a page 2 27
As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now