我有一个从数据库中获取数据的动态表。
我希望工具提示出现在$row['The_Job']
中的列。但与此同时,重要的是此列对单元格内的数据(而不是工具提示(具有一定的样式。我在下面附上了 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;
}
我应该怎么做?我应该添加什么CSS以及如何更改php代码?
HTML
title
属性表示鼠标悬停时用于工具提示的文本。因此,在需要工具提示的位置(例如在 <td>
元素中(,请包含 title="tooltip text"
。Tha 显示不可设置样式的内置(浏览器(工具提示。
对于您稍后在注释中引用的其他自定义样式的工具提示,您的代码可能看起来更像这样(为简洁起见,我只包含您指出需要工具提示的单元格(:
<td class="job-style">
<div class="tooltip">'.$row['The_Job'].'
<span class="tooltiptext">Tooltip text</span>
</div>
</td>