gpt4 book ai didi

html - 突出显示斑马线表格中的行和列并保存单元格边框

转载 作者:行者123 更新时间:2023-11-28 07:26:52 25 4
gpt4 key购买 nike

我有斑马线剥离表,我已经可以突出显示列和行,但由于某种原因,突出显示列中的单元格边框是 z-index 低于(:之后)元素,即使在标题中,单元格背景更高,但是边界仍在下方。因此,我需要突出显示斑马线剥离表中的行和列并保存单元格边框。 没有 javascript

HTML:

<table class="table">
<thead>
<tr class="table__row table__row_header">
<th class="table__cell table__cell_header">title 1</th>
<th class="table__cell table__cell_header">title 2</th>
<th class="table__cell table__cell_header">title 3</th>
<th class="table__cell table__cell_header">title 4</th>
<th class="table__cell table__cell_header">title 5</th>
</tr>
</thead>
<tbody>
<tr class="table__row table__row_body">
<td class="table__cell table__cell_body">
<span class="table__content">text 11</span>
</td>
<td class="table__cell table__cell_body">
<span class="table__content">text 12</span>
</td>
<td class="table__cell table__cell_body">
<div class="table__content">text 13</div>
</td>
<td class="table__cell table__cell_body">
<div class="table__content">text 14</div>
</td>
<td class="table__cell table__cell_body">
<span class="table__content">text 15</span>
</td>
</tr>

<tr class="table__row table__row_body">
<td class="table__cell table__cell_body">
<span class="table__content">text 21</span>
</td>
<td class="table__cell table__cell_body">
<span class="table__content">text 22</span>
</td>
...
</tr>
...
</tbody>
</table>

CSS:

.table {
overflow: hidden;
width: 80%;
margin: 5px auto 5px auto;
font-size: 16px;
cursor: default;
}
.table__row {
position: relative;
}
.table__row_body:nth-child(even) {
background-color: darkgrey;
}
.table__row_body:nth-child(odd) {
background-color: lightgrey;
}
.table__cell {
position: relative;
padding: 10px;
border: 10px solid cadetblue;
border-collapse: collapse;
}
.table__cell_header {
z-index: 20;
background-color: darkslategrey;
color: white;
}
.table__cell_body:hover:after {
position: absolute;
z-index: 10;
top: -5000px;
left: 0;
width: 100%;
height: 10000px;
content: "";
background-color: lightyellow;
}
.table__row_body:hover .table__cell_body {
background-color: lightgoldenrodyellow;
}
.table__content {
position: relative;
z-index: 20;
}

What I need (mostly in Chrome)

Source

最佳答案

找到将高亮颜色更改为边框颜色并使其有点透明的解决方案:

background-color: rgba(95,158,160,.5);    

代替

background-color: lightyellow;
background-color: lightgoldenrodyellow;

Result

关于html - 突出显示斑马线表格中的行和列并保存单元格边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31761622/

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