jquery - 悬停动画到 HTML 表格

标签 jquery html css

悬停时我想在桌面上显示动画

<table border="1">
<tr>
        <th>Firstname</th>
        <th>Lastname</th> 
        <th>Age</th>
</tr>
<tr>
        <td>Jill</td>
        <td>Smith</td> 
        <td>50</td>
 </tr>
 <tr>
        <td>Eve</td>
        <td>Jackson</td> 
        <td>94</td>
</tr>
</table>

enter image description here 我添加了我真正想要的图像

最佳答案

可以考虑使用伪元素实现这样的效果:

table {
 position:relative;
 z-index:0;
 overflow:hidden;
}
td {
  position:relative;
}
td:hover::before,
td:hover::after{
  content:"";
  position:absolute;
  z-index:-1;
  background:yellow;
}
td:hover::before{
  top:0;
  bottom:0;
  right:-50vw;
  left:-50vw;
}
td:hover::after {
  left:0;
  right:0;
  top:-50vh;
  bottom:-50vh;
}
<table border="1">
  <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table>

关于jquery - 悬停动画到 HTML 表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54056203/

相关文章:

javascript - ng-class 在满足条件后不立即设置类

javascript - 使用 jquery 中的 onclick 事件更改 HTML 属性值

javascript - 仅对移动设备禁用某些 javascript 代码

html - 在文章中嵌套部分是一个 SEO 智慧的好主意吗?

css - 如何自动调整网格元素的大小以适应父级高度

html - 高级 CSS 数据选择器——SASS 还是 RegEx?

javascript - JQuery Datepicker 在 IE 中不工作,在 Firefox 和 Chrome 中工作正常

html - 边缘的 CSS 背景颜色

html - 隐藏标签

css - 如何将 block 项与其父项的右边缘对齐(使用 CSS)?