我在表格中对单元格进行CSS格式化时遇到了一些困难。单元格需要具有与表中其他单元格不同的背景颜色,列跨度和对齐方式。内嵌样式工作正常,但我想将样式移动到CSS。
这是我在CSS中的内容:
/*Color and formatting the background on cal_parameter*/
.calParameter
{
background-color:darkgray;
column-span:all;
align-content:center;
}
由于某些原因,CSS不应用column-span和align-text属性,但背景颜色为。
这种直线造型效果正确:
<td class="calParameter" colspan="8" align="center">@Html.DisplayFor(modelitem => data.cal_points.cal_parameter)</td>
这种CSS样式无法正常工作:
<td class="calParameter">@Html.DisplayFor(modelitem => data.cal_points.cal_parameter)</td>
TIA, ~~~崔西
答案 0 :(得分:0)
这对我有用,希望它能解决你的问题。
对于细胞间距使用:
table {border-spacing: 8px 2px;}
对于细胞填充使用:
td{padding: 6px;}
答案 1 :(得分:0)
.calParameter {
background-color:darkgray;
text-align:center;
}
保留colspan属性并删除align属性。将你的CSS改为我上面的内容。 colspan是为html td制作的属性。
答案 2 :(得分:0)
您滥用CSS属性!
colspan
没有css等价物。它是TD表 HTML属性,而column-span
使得元素跨越列,并且只能使用column-count
https://developer.mozilla.org/en-US/docs/Web/CSS/column-span
答案 3 :(得分:0)
试试这个,它对我有用,希望它对你也有用。
var nama = [
{% for key, student in students %}
{{ student }}
{% endfor %}
];
有关详细信息,请参阅此详细示例。