gpt4 book ai didi

javascript - 在悬停时突出显示表格行显示列之间的空白

转载 作者:行者123 更新时间:2023-11-28 13:45:48 24 4
gpt4 key购买 nike

我一直在寻找这个问题的答案,但在网上找不到。

基本上我想在用户将鼠标悬停在表格行上时突出显示它。

我可以使用 css 或 jquery 来做到这一点,但它们都显示了列之间的空白区域,所以它看起来很丑陋。

请问有没有办法解决这个问题?

列间隔的方式是在 html 的表声明中使用 cellspacing

<script type="text/javascript">
$(document).ready(function(){
$('.highlight').hover(function(){
$(this).children().addClass('datahighlight');
},function(){
$(this).children().removeClass('datahighlight');
});
});
</script>`

<table class="gig-table" cellspacing="30">
<tr class="highlight">`

在 CSS 中:

.datahighlight { background-color:#cc0099 !important; }

最佳答案

使用:

 <table cellspacing="0" cellpadding="0">

如果你想在你的单元格中有空格,请使用 CSS:

  td {padding:10px;}
tr:hover {background-color:magenta;} /* does not works in old IE versions */

关于javascript - 在悬停时突出显示表格行显示列之间的空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5312676/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com