Solved

CSS Menu with Table Cell Rollover

Posted on 2006-06-15
9
241 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change CSS to show Notification Bar 9 36
Location of Buttons 4 18
Change Firefox bookmarks menu font size 2 34
Why "Mobile First"? 5 20
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

830 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