html - 有没有办法建立从表格到行/单元格的链接?
问题描述
我需要一个词,当单击(如链接)时,它将转到表格上的特定行,所有这些都在同一页面上。我有一个这种格式的表:
<div id="table1">
<table width='100%' id = 'table1'>
<tr>
<th><b>Coluna1:</b></th>
<th><b>Coluna2:</b></th>
</tr>
<tr>
<td>Word1</td>
<td>Text1</td>
</tr>
<tr>
<td>Word2</td>
<td>Text2</td>
</tr>
<tr>
<td>Word3</td>
<td>Word3</td>
</tr>
</table>
我怎样才能做到这一点?
解决方案
是的,您可以通过id
为要转到的每一行/单元格设置 s 并链接到 s来做到这一点#<id>
。
@keyframes highlight {
from { background-color: yellow; }
to { background-color: #0000; }
}
:target {
animation: highlight 1s linear;
}
<p>Go to</p>
<ul>
<li><a href="#word1">Word1</a></li>
<li><a href="#text1">Text1</a></li>
<li><a href="#row1">Row1</a></li>
<li><a href="#text2">Text2</a></li>
</ul>
<table width='100%' id ="table1">
<tr>
<th><b>Coluna1:</b></th>
<th><b>Coluna2:</b></th>
</tr>
<tr id="row1">
<td id="word1">Word1</td>
<td id="text1">Text1</td>
</tr>
<tr id="row2">
<td id="word2">Word2</td>
<td id="text2">Text2</td>
</tr>
<tr>
<td>Word3</td>
<td>Word3</td>
</tr>
</table>
推荐阅读
- httpclient - Micronaut 声明式 Http 客户端需要 @Body 或者您在 JSON 请求中获得一个密钥
- javascript - 如果文件不是图像,则在加载时显示甜蜜警报
- kubernetes - nfs-provisioner 无法创建共享文件夹
- python - Scrapy 管道已启用但从未使用过
- javascript - React Native JSON Parse error Unexpected identifier
- javascript - Javascript 倒计时议程项目对象
- javascript - 我想将数据从烧瓶传回 React 并基于它呈现 html
- xaml - 如何设置与UWP中给定颜色相对应的ColorSpectrum内的圆圈位置?
- python - Python中的if和range
- python - BS4 | 蟒蛇 | 用多个值抓取 div 中的特定数据