在做项目中,设置了table中td的宽度的百分比,但是并没有起作用,这是因为table-layout行的宽度默认是automatic(列宽度由单元格内容设定。)
这时只需要设置table如下样式即可:
table{
table-layout:fixed
}
table-layout 有三个属性:
automatic(列宽度由单元格内容设定。)
fixed(列宽由表格宽度和列宽度设定。)
inherit(规定应该从父元素继承 table-layout 属性的值)
在做项目中,设置了table中td的宽度的百分比,但是并没有起作用,这是因为table-layout行的宽度默认是automatic(列宽度由单元格内容设定。)
这时只需要设置table如下样式即可:
table{
table-layout:fixed
}
table-layout 有三个属性:
automatic(列宽度由单元格内容设定。)
fixed(列宽由表格宽度和列宽度设定。)
inherit(规定应该从父元素继承 table-layout 属性的值)