2

I have a web page that has an image inside of a table cell that I only want to show when you hover over a cell.

The issue I have is that it "pushes" the other text to the left when the image is shown (because the default state is display:none"). I am looking for a solution that does

In a table cell, i have an image that is on the top right using this code:

 <td class="tableCell">
        <span class="cellMenu">
           <img src="/Icons/arrow_down.png" class="seatMenuArrow">
        </span>
        A bunch of other text that is all center aligned
 </td>

Here is the css that makes the cellMenu image top right.

.cellMenu
{
    display:none;
    float:right;
    cursor: pointer;
}

and I am doing this to show the instrument only when you hover over the cell.

$('.tableCell').live('hover', function () {
      $(this).toggleClass("hover").find(".cellMenu").toggle();
});

This works but when the images is shown the "A bunch of other text that is all center aligned" moves over. What is the correct way to avoid having this move over so the image is just shown and nothing else moves?

leora
  • 188,729
  • 360
  • 878
  • 1,366

1 Answers1

1

Do it without jQuery:

.cellMenu img
  {
    opacity:0;
    float:right;
    cursor: pointer;
  }

.cellMenu:hover img
  {
     opacity: 1;
  }

Added a JSfiddle

Rvervuurt
  • 8,589
  • 8
  • 39
  • 62