ballouta Posted April 25, 2008 Share Posted April 25, 2008 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 https://forums.phpfreaks.com/topic/102929-changing-cells-color-when-mouse-over/ Share on other sites More sharing options...
atl_andy Posted April 26, 2008 Share Posted April 26, 2008 It's quite simple to do. Google is your friend. Link to comment https://forums.phpfreaks.com/topic/102929-changing-cells-color-when-mouse-over/#findComment-527892 Share on other sites More sharing options...
ToonMariner Posted April 27, 2008 Share Posted April 27, 2008 us the td:hover in your css... you will have to use javascript to add a onmouseover and onmouseout event for ie6... Link to comment https://forums.phpfreaks.com/topic/102929-changing-cells-color-when-mouse-over/#findComment-528517 Share on other sites More sharing options...
Skittalz Posted April 29, 2008 Share Posted April 29, 2008 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 https://forums.phpfreaks.com/topic/102929-changing-cells-color-when-mouse-over/#findComment-529282 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.