将 HTML Table 放在图标内的工具提示中
Putting HTML Table in a tooltip inside an icon
我一直在尝试将 table 放在图标内的工具提示中,主要目标是创建一个小图例来解释 [=25] 中这些 colors using this icon 的含义=]颜色.
到目前为止,我只设法使图标出现,但没有进一步成功。我在 "Color" 列中制作的 table 现在它只显示颜色的名称,但我想显示一个小方块,用代表的颜色绘制,即红色方块红色,蓝色方块代表蓝色...等等。
这是我编写的代码:
<style>
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 180px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
</style>
<a>
<span class="tooltip">
<i class="fas fa-info-circle"></i>
<table class="tooltiptext">
<thead>
<tr>
<th>Color</th>
<th>Significado</th>
<tr>
</thead>
<tbody>
<tr>
<th>Gris</th>
<th>Comprado</th>
</tr>
<tr>
<th>Verde</th>
<th>Emergencia</th>
</tr>
<tr>
<th>Verde</th>
<th>Urgencia</th>
</tr>
<tr>
<th>Verde</th>
<th>Urgencia Menor</th>
</tr>
<tr>
<th>Verde</th>
<th>Sin Urgencia</th>
</tr>
</tbody>
</table>
</span>
</a>
编辑:这是其中的一小部分 snippet。
我可以使用 bootstrap 和 javascript 来完成,我使用 js 是为了避免 visual studio 出现一些小问题,因为编译器不允许我这样做将 class 属性放入 bootstrap 工具提示的标题属性中。
代码如下:
<a id="information" data-toggle="tooltip" data-html="true">
<span><i class="fas fa-info-circle" style="color: #ff9900"></i></span>
</a>
function info() {
var infoTooltip = document.getElementById("information");
infoTooltip.setAttribute("title",
`
<table>
<thead>
<tr>
<th>Colores</th>
</tr>
</thead>
<tbody>
<tr>
<th><span class="badge badge-danger px-2">Emergencia</span></th>
</tr>
<tr>
<th><span class="badge badge-warning px-2">Urgencia</span></th>
</tr>
<tr>
<th><span class="badge badge-success px-2">Urgencia Menor</span></th>
</tr>
<tr>
<th><span class="badge badge-primary px-2">Sin Urgencia</span></th>
</tr>
<tr>
<th><span class="badge badge-light px-2">Comprado</span></th>
</tr>
</tbody>
</table>
`
);
}
这是outcome。
我一直在尝试将 table 放在图标内的工具提示中,主要目标是创建一个小图例来解释 [=25] 中这些 colors using this icon 的含义=]颜色.
到目前为止,我只设法使图标出现,但没有进一步成功。我在 "Color" 列中制作的 table 现在它只显示颜色的名称,但我想显示一个小方块,用代表的颜色绘制,即红色方块红色,蓝色方块代表蓝色...等等。
这是我编写的代码:
<style>
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 180px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
</style>
<a>
<span class="tooltip">
<i class="fas fa-info-circle"></i>
<table class="tooltiptext">
<thead>
<tr>
<th>Color</th>
<th>Significado</th>
<tr>
</thead>
<tbody>
<tr>
<th>Gris</th>
<th>Comprado</th>
</tr>
<tr>
<th>Verde</th>
<th>Emergencia</th>
</tr>
<tr>
<th>Verde</th>
<th>Urgencia</th>
</tr>
<tr>
<th>Verde</th>
<th>Urgencia Menor</th>
</tr>
<tr>
<th>Verde</th>
<th>Sin Urgencia</th>
</tr>
</tbody>
</table>
</span>
</a>
编辑:这是其中的一小部分 snippet。
我可以使用 bootstrap 和 javascript 来完成,我使用 js 是为了避免 visual studio 出现一些小问题,因为编译器不允许我这样做将 class 属性放入 bootstrap 工具提示的标题属性中。
代码如下:
<a id="information" data-toggle="tooltip" data-html="true">
<span><i class="fas fa-info-circle" style="color: #ff9900"></i></span>
</a>
function info() {
var infoTooltip = document.getElementById("information");
infoTooltip.setAttribute("title",
`
<table>
<thead>
<tr>
<th>Colores</th>
</tr>
</thead>
<tbody>
<tr>
<th><span class="badge badge-danger px-2">Emergencia</span></th>
</tr>
<tr>
<th><span class="badge badge-warning px-2">Urgencia</span></th>
</tr>
<tr>
<th><span class="badge badge-success px-2">Urgencia Menor</span></th>
</tr>
<tr>
<th><span class="badge badge-primary px-2">Sin Urgencia</span></th>
</tr>
<tr>
<th><span class="badge badge-light px-2">Comprado</span></th>
</tr>
</tbody>
</table>
`
);
}
这是outcome。