[英]How to make a tooltip inside a table cell in html
I have a dynamic table that gets data from a database. 我有一个从数据库获取数据的动态表。
The column that I want a tooltip to appear in $row['The_Job']
. 我希望工具提示显示在
$row['The_Job']
。 But at the same time, it is important that this column has certain styling for the data that is inside the cell (not the tooltip). 但同时,重要的一点是,此列对单元格内部的数据(而不是工具提示)具有特定的样式。 I have attached the CSS
.job-styling
below. 我在下面附上了CSS
.job-styling
。
<?php
$sql = "SELECT * FROM request_data;";
$conn = Connect();
mysqli_set_charset($conn,'utf8');
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result); //<td class="job-style">'.$row['The_Job'].'</td>
if ($resultCheck > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo '<table style = "width:100%">
<tr>
<td style = "width:13%">'.$row['ID'].'</td>
<td class="job-style">'.$row['The_Job'].'</td>
<td style = "width:8%">'.$row['Paymentfro'].'-'.$row['Paymentto'].'</td>
<td style = "width:8%">'.$row['Amount'].'</td>
<td style = "width:10%">'.$row['Urgency'].'</td>
<td style = "width:8%">'.$row['Difficulty'].'</td>
</tr>
</table>';
}
}
?>
.job-style {
max-width:100px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
How should I do it? 我该怎么办? What CSS should I add and how to change the php code?
我应该添加什么CSS,以及如何更改php代码?
The HTML title
attribute denotes text to be used for a tooltip on mouse hover. HTML
title
属性表示要用于鼠标悬停时的工具提示的文本。 So where you want the tooltip, for example in a <td>
element, include title="tooltip text"
. 因此,在需要工具提示的位置(例如在
<td>
元素中),请包含title="tooltip text"
。 Tha displays built-in (browser) tooltips which aren't styleable. Tha显示无法设置样式的内置(浏览器)工具提示。
For the other, custom-styled tooltips you referenced later in your comment, your code should probably look more like this (for brevity I've included just the cell you pointed out as needing a tooltip): 对于您稍后在注释中引用的其他自定义样式的工具提示,您的代码应该看起来更像这样(为简便起见,我仅包括您指出的需要工具提示的单元格):
<td class="job-style">
<div class="tooltip">'.$row['The_Job'].'
<span class="tooltiptext">Tooltip text</span>
</div>
</td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.