【问题标题】:<br> tag not working in table td data-title attribute<br> 标签在表 td 数据标题属性中不起作用
【发布时间】:2018-11-26 11:52:47
【问题描述】:

我想为响应式数据表添加数据标题属性。而td data-title 包含 break 语句标签。但是 break 语句标签不起作用。下面是我的示例代码,

<td data-title='Goods<br>Code'></td>

我想要两行中的“商品”和“代码”。

【问题讨论】:

  • 你不能在data-属性中使用HTML标签。

标签: html


【解决方案1】:

我认为data-*属性只支持字符串,html代码不会影响它所以尝试改变

<td data-title='Goods<br>Code'></td>

<td data-title="Goods\nCode"></td>

\n 换行

编辑

尝试添加data-html="true" 我看到这个答案请检查一下 https://stackoverflow.com/a/13705417/5441049

或者使用JQuery工具提示插件

https://www.w3schools.com/bootstrap/bootstrap_ref_js_tooltip.asp

【讨论】:

【解决方案2】:

这个应该可以:

#table th, #table td{
    padding:0.8em;
    border: 1px solid;
}
#table th{
    background-color:#6699FF;
    font-weight:bold;
}
<table id="table">
  <tr>
        <th>ID</th>
        <th>Text</th>
       
    </tr>
 <tr>
        <td>1</td>
        <td title="Goods&#010;Code">Hover Me</td>
    </tr>
</table>

只需运行 sn-p 并将鼠标悬停在“悬停我”单元格上,您应该会看到您想要的标题。

"&#013; is \r and &#010; is \n
On Windows new line is &#013;&#010; on unix &#010;"

【讨论】:

  • 我正在使用这个 data-title 属性来获取响应式数据表。如果我只使用标题,则什么都不可见。
  • 我很快就会想出一个解决 data-title 属性的方法
  • 有人提出解决方案了吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-11-09
  • 2023-03-08
  • 1970-01-01
  • 1970-01-01
  • 2016-10-29
  • 2018-05-03
  • 1970-01-01
相关资源
最近更新 更多