使用colspan属性构建HTML表格时遇IDE标记未知属性问题
解决表格单元格跨列及IDE报错问题
问题根源
你把colspan这个HTML专属属性写到SCSS文件里了,IDE自然会标记为未知属性——它不属于CSS属性范畴,只能直接写在HTML的<td>标签上。
正确实现代码
给<tbody>里的每个<td>添加colspan="3"(表头共3列,跨3列即可占满整个表格宽度),修改后的完整HTML代码如下:
<table> <thead> <th class="col-4"> Placeholder </th> <th class="col-5"> Placeholder </th> <th> <button> <em class="fa fa-trash-alt"></em> </button> </th> </thead> <tbody> <tr> <td colspan="3"><strong>Description: </strong></td> </tr> <tr> <td colspan="3"><strong>Opportunities: </strong></td> </tr> <tr> <td colspan="3"><strong>Risks: </strong></td> </tr> <tr> <td colspan="3"><strong>Dependencies: </strong></td> </tr> </tbody> </table>
补充说明
colspan的取值要和表头列数对应,这里表头是3列,设为3就能让单元格跨满整个表格宽度。- 所有HTML属性都需直接写在对应HTML标签上,不要放到CSS/SCSS文件中,避免IDE报错和功能失效。
内容的提问来源于stack exchange,提问作者liberlux
相关产品推荐
相关产品推荐

