javascript - Fix covering hovered table / hovering problem with table
问题描述
I have a problem with creating table. I need to create a table with some of cells with hover/tooltip event. For example when I point to the cell, I need to show one column table with links, but when do this in that way I have problem with overlaping (I can't use links from first cell). For now I only tried to use CSS and HTML, but soltuion with JS is also accepted.
HTML:
<div class="ttip">
<a class="foo">FOO</a>
<table>
<tr>
<td><a href='bar'>Bar</a></td>
</tr>
<tr>
<td><a href='baz'>Baz</a></td>
</tr>
</table>
</div>
<div class="ttip">
<a class="foo">FOO2</a>
<table>
<tr>
<td><a href='bar2'>Bar2</a></td>
</tr>
<tr>
<td><a href='baz2'>Baz2</a></td>
</tr>
</table>
</div>
Style:
.ttip {
position: relative;
display: table;
}
.ttip>table {
position: absolute;
white-space: nowrap;
border-collapse: collapse;
display: none;
}
.ttip>table td {
border: 1px dotted #000;
padding: 2px;
}
.ttip:hover>table {
display: table;
}
Live:
https://jsfiddle.net/uLm0gjcn/3/
Regards
解决方案
The FOO2 is rendered after the FOO , meaning when its displayed, its technically below FOO2 text. To fix that you need to apply z-index
in your css here in .ttip>table
.ttip>table {
position: absolute;
white-space: nowrap;
border-collapse: collapse;
display: none;
z-index: 1;
}
This way, when the drop-down/tool-tip appears from FOO, it is rendered on top of FOO2.
Edit. Also, to make it not transparent, apply a background-color
to css in .ttip>table
. for example for a white background background-color: white;
推荐阅读
- javascript - javascript中的计时器显示错误,我该如何解决?
- google-cloud-platform - 我该如何处理:错误:(gcloud.compute.ssh)?
- json - 使用 POST 方法将带有 JSONObject Volley 库的数据发送到服务器
- reactjs - React Native,映射 JSON
- javascript - 查询数据库时 AJAX jQuery 不起作用
- java - 比较2个数组并区分Java中相同位置的相同值和不同位置的相同值
- javascript - 为什么光标不只定位在 FireFox 的末尾?
- python - 有没有办法将一个 Pytorch 模型的所有参数复制到另一个专门的批量标准化平均值和标准?
- broadcast - 后台服务不工作应用程序在 android 8.0.1 中崩溃
- sql - 如何在 PostgreSQL 查询中跳过空值?