首页 文章

当鼠标越过表中的一行时,将光标更改为手

提问于
浏览
162

当鼠标移过 <tr> <tr> 时,如何将光标指针更改为手形

<table class="sortable" border-style:>
  <tr>
    <th class="tname">Name</th><th class="tage">Age</th>
  </tr>
  <tr><td class="tname">Jennifer</td><td class="tage">24</td></tr>
  <tr><td class="tname">Kate</td><td class="tage">36</td></tr>
  <tr><td class="tname">David</td><td class="tage">25</td></tr>
  <tr><td class="tname">Mark</td><td class="tage">40</td></tr>
</table>

10 回答

  • 8

    我搜索了一些bootstrap样式,发现了这个:

    [role=button]{cursor:pointer}
    

    所以我假设你可以得到你想要的东西:

    <span role="button">hi</span>
    
  • 60

    我发现最简单的方法是添加

    style="cursor: pointer;"
    

    到你的标签 .

  • 10

    cursor: pointer 添加到您的CSS .

  • 11

    我将它添加到我的style.css来管理光标选项:

    .cursor-pointer{cursor: pointer;}
    .cursor-croshair{cursor: crosshair;}
    .cursor-eresize{cursor: e-resize;}
    .cursor-move{cursor: move;}
    
  • 289

    为了与IE <6兼容,请按以下顺序使用此样式:

    .sortable:hover {
        cursor: pointer;
        cursor: hand;
    }
    

    但请记住,IE <7仅支持带有 <a> 元素的 :hover 伪类 .

  • 1

    在CSS中使用样式 cursor: pointer; 作为您希望光标更改的元素 .

    在您的情况下,您将使用(在您的.css文件中):

    .sortable {
        cursor: pointer;
    }
    
  • 15

    你可以用CSS实际做到这一点 .

    .sortable tr {
        cursor: pointer;
    }
    
  • 23

    像这样使用CSS游标属性:

    <table class="sortable">
      <tr>
        <th class="tname">Name</th><th class="tage">Age</th>
      </tr>
      <tr style="cursor: pointer;"><td class="tname">Jennifer</td><td class="tage">24</td></tr>
      <tr><td class="tname">Kate</td><td class="tage">36</td></tr>
      <tr><td class="tname">David</td><td class="tage">25</td></tr>
      <tr><td class="tname">Mark</td><td class="tage">40</td></tr>
    </table>
    

    当然,您应该将样式放入CSS文件并将其应用于类 .

  • 4

    用css

    table tr:hover{cursor:pointer;} /* For all tables*/
    table.sortable tr:hover{cursor:pointer;} /* only for this one*/
    
  • 187

    上述解决方案仅适用于标准,但如果您使用数据表,则必须覆盖默认的datatatables.css设置并将以下代码添加到自定义css中 . 在下面的代码中,row-select是我在datatables上添加的类如html中所示 .

    table.row-select.dataTable tbody td
    {
    cursor: pointer;    
    }
    

    你的HTML将如下所示:

    <table datatable="" dt-options="dtOptions1" dt-columns="dtColumns1" class="table table-striped table-bordered table-hover row-select"  id="datatable"></table>
    

相关问题