Solved

CSS Menu with Table Cell Rollover

Posted on 2006-06-15
9
213 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…

747 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

12 Experts available now in Live!

Get 1:1 Help Now