Jump to content

Changing cell's Color when mouse over


ballouta

Recommended Posts

Hello

 

Is it possible to change a cell color when moving the mouse over it? How?

 

Am I able to make a nice decoration on the left, i saw before some cells have a small colored column on the left before the text? can this be done by html code or it is an image background?

 

i have thi simple table (menu):

 

	<table border="1" width="11%" id="table1" bgcolor="#808000" cellspacing="0" cellpadding="0" bordercolor="#000000">
	<tr>
		<td>
		<p dir="ltr">Button 1</td>
	</tr>
	<tr>
		<td>
		<p dir="ltr">Button 2</td>
	</tr>
	<tr>
		<td>
		<p dir="ltr">Button 3</td>
	</tr>
</table>

 

thank you

Link to comment
Share on other sites

Hey ballouta,

 

To change a cell's color when you hover the mouse over it, simply add this code to the TD element

 

bgcolor='#HEXADECIMAL' onmouseover="style.backgroundColor='#HEXADECIMAL" onmouseout="style.backgroundColor='#HEXADECIMAL'"

 

If you want a smooth flowing highlight, 'bgcolor' and 'onmouseout' should be the same color or hexadecimal.

 

So in your case for your button, the code would look like this

 

	<table border="1" width="11%" id="table1" bgcolor="#808000" cellspacing="0" cellpadding="0" bordercolor="#000000">
	<tr>
		<td bgcolor="#808000" onmouseover="style.backgroundColor='#404040'" onmouseout="style.backgroundColor='#808000'">
		<p dir="ltr">Button 1</p> <!--Remember to close your tags! It will help when you learn XHTML! -->
                                      </td>
	</tr>
	<tr>
                                      <td bgcolor="#808000" onmouseover="style.backgroundColor='#404040'" onmouseout="style.backgroundColor='#808000'">
		<p dir="ltr">Button 2</p> 

	</tr>
	<tr>
                                      <td bgcolor="#808000" onmouseover="style.backgroundColor='#404040'" onmouseout="style.backgroundColor='#808000'">
		<p dir="ltr">Button 3</p> 
	</tr>
</table>

 

 

The decoration you probably saw could have been an image. To use an image for roll over, its a bit different.

 

To use and change images when you hover your mouse, use the following code

 

background='imageurl/bgimage.gif' onmouseover=style.backgroundImage="url('imageurl/bgimage2')"; onmouseout=style.backgroundImage="url('imageurl/bgimage.gif')";

 

Just file in the correct image url and you should be flying

 

Hope this helped!

 

SKitTalZ

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.