【发布时间】:2013-03-14 15:00:00
【问题描述】:
我有这样的场景,我有动态生成的表。表可能包含数字字段以及文本字段。我给那个表一个特定的 CSS。我想要在表格中有文本字段的地方我给text-align: center;,在表格中有数字字段的地方我给text-align: right; 我可以使用单个Id/Class应用CSS吗?我们可以给if condition 识别表格字段是CSS 文件中的数字还是文本?
这是我动态生成的表格
<table class="alignCSS">
<thead>
<tr>
<th>
Doctor Name
</th>
<th>
Amount
</th>
</tr>
</thead>
<tbody>
<% foreach (var item in Model) { %>
<tr>
<td>
<%: Html.DisplayFor(modelItem => item.Doctor_Name) %>
// text field here i want to apply center alignment using CSS
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Amount) %>
//number field here i want to apply right alignment using CSS
</td>
</tr>
<% } %>
</tbody>
</table>
【问题讨论】:
-
显示生成表格的代码。
-
@DarinDimitrov 我已经编辑了我的问题。并添加动态生成的表格代码。
标签: css asp.net-mvc conditional