html - 如何在 HTML <table> 中的 <td> 元素中设置列?

标签 html css razor asp.net-mvc-5

以下输出:

enter image description here

由以下代码提供:

<table class="table container">
  <tr>
    <th class="col-md-1 text-center">
      @Html.DisplayNameFor(Function(model) model.SurveyResults.FirstOrDefault().QuestionNum)
    </th>
    <th class="col-md-2 text-center">
      @Html.DisplayNameFor(Function(model) model.SurveyResults.FirstOrDefault().QuestionText)
    </th>
    .
    .
    .
    <th class="col-md-2">
      @Html.DisplayNameFor(Function(model) model.SurveyResults.FirstOrDefault().Answers)
    </th>
  </tr>

  @For Each item In Model.SurveyResults
    @<tr>
      <td class="col-md-1 text-center">
        @Html.DisplayFor(Function(modelItem) item.QuestionNum)
      </td>
      <td class="col-md-2">
        @Html.DisplayFor(Function(modelItem) item.QuestionText)
      </td>
    .
    .
    .
      <td class="col-md-2">
        @For Each ans In item.Answers
          @ans.AnswerText
          @ans.AnswerStats
          @<br />
        Next
      </td>
    </tr>
  Next
</table>

Answers 列中,括号中的字符串是有关答案的统计信息。我希望统计数据显示为 Answers 右侧的另一列。答案最终会有不同的长度,并且统计数据需要显示在垂直排列的右侧。上面的代码将始终在答案文本的末尾显示统计信息,无论何时出现。

我尝试了 SO 和其他论坛的一些想法,但无法弄清楚如何在每个 行的 Answers 元素中轻松创建 2 个“子列”。我想坚持使用 Razor/HTML 代码。

最佳答案

您必须在 answers td 元素中添加另一个表格。

我认为这非常相似: Html table tr inside td

关于html - 如何在 HTML <table> 中的 <td> 元素中设置列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32684462/

相关文章:

css - 如何使用 React-Bootstrap 映射()行中的元素

c# - MVC 提交按钮未触发

c# - MVC Razor 路由建议

javascript - 使用 Angular 从下拉列表中获取选定的值

html - IE10/11 显示垂直滚动条变成空?

php - jQuery .animate 不起作用

javascript - jQuery sibling 不工作?

css - 更改由 :after pseudo-element as its parent? 创建的 CSS 形状的颜色

html - 在 HTML5 全屏视频上叠加

authentication - 如何在 Razor 中进行 Active Directory 身份验证 (cshtml)