为什么 x% 不是 Visual Studio 中属性 'width' 的有效值?
Why x% is not a valid value of attribute 'width' in Visual Studio?
我正在尝试创建一个可扩展的 table,所以我将它的值设置为 %。该网站运行正常,但为什么 Visual Studio 将其视为无效?
它可能正在使用一组处理最佳实践的代码分析规则。根据 the MDN web docs,width
属性已被弃用,不应使用:
Do not use this attribute, as it has been deprecated. The rules should be defined and styled using CSS.
如前所述,您应该使用 CSS 来设置 table 的样式。将 class 应用于 table 元素并定义样式:
HTML
<table class="my-table"></table>
CSS
.my-table {
width: 100%;
}
我正在尝试创建一个可扩展的 table,所以我将它的值设置为 %。该网站运行正常,但为什么 Visual Studio 将其视为无效?
它可能正在使用一组处理最佳实践的代码分析规则。根据 the MDN web docs,width
属性已被弃用,不应使用:
Do not use this attribute, as it has been deprecated. The rules should be defined and styled using CSS.
如前所述,您应该使用 CSS 来设置 table 的样式。将 class 应用于 table 元素并定义样式:
HTML
<table class="my-table"></table>
CSS
.my-table {
width: 100%;
}