6

我有一个行表(duh),在其中一列中,我试图在悬停/鼠标悬停期间出现两个按钮。现在,它是一个具有设定宽度/高度和背景位置的锚标记。

这是它们不隐藏时的样子:

成品的一个很好的例子是grooveshark的悬停控件:

基本上,我想知道如何隐藏所有图像,除了当前悬停在一行中的图像。然后该行将显示这些图像,但一旦鼠标移动到不同的行就会消失。

html代码:

echo '<td><a href="/servers/detail.php?id='. $row['id'] .'">'.$row['server_name'].'</a><a id="option-favorite" class="rowOption"></a><a id="option-vote" class="rowOption"></a></td>';

JS代码:

jQuery('td').live('mouseover', function () {
    jQuery(this).closest("tr").find('a.rowOption').visible();
});
4

2 回答 2

23

当您有行表(duh)时,您可以像这样使用 CSS:

  table#mytableofrows tr td a.button { display:none;}
  table#mytableofrows tr:hover td a.button { display:inline-block;}

将适用于此标记:

<table id="mytableofrows" width="100%">
    <tr><td> <a class="button">Hello yes this is dog</a> </td></tr>
</table>
于 2012-04-15T02:34:06.517 回答
7

尝试使用 HTML5 样式标签。

<!DOCTYPE html>
<html>
  <head>
    <style type="text/css">
      table tr button { opacity:0; float:right }
      table tr:hover button { opacity:1 }
    </style>
  </head>

  <body>
    <table border=1 width=300px>
      <tr><td>LINE1 <button>BUTTON1</button></td></tr>
      <tr><td>LINE2 <button>BUTTON2</button></td></tr>
      <tr><td>LINE3 <button>BUTTON3</button></td></tr>
    </table>
  </body>
</html>
于 2012-08-16T20:34:27.970 回答