html - <table> 样式元素未显示

标签 html css asp.net-mvc

我在 Intranet 上工作,特别是在可以打印的报告页面上,显示一个网格,其中包含员工在选定月份的工作小时数。这是它现在的样子的屏幕截图:

enter image description here

如您所知,信息的显示没有太多的分离和清晰度。

这是显示所有内容的 View 部分:

  <table> 

    <tr>
        <th>Date</th>
        <th>Activité</th>
    </tr>
<%

    int total = 0;
    int i = 0;
    foreach (var jour in ViewBag.ListDaysOfMonth)
    {
        if (ViewBag.ReportInts.Length > i)
        {
            total += decimal.Parse(ViewBag.ReportInts[i]);

            if (jour.Contains("Mo") && i != 0)
            {
            %>

            <tr>
            <td colspan="2">&nbsp;
            </td>
            </tr>

            <%
            }  
            %>

            <tr>
            <td width="150"><%= jour%>&nbsp;</td>
            <td><%= ViewBag.ReportInts[i++]%></td>
            </tr>
<%
        }
        else
        {
%>
            <tr>
            <td align="center" colspan="2">Aucune activité.</td>
            </tr>
<%
        }
    }
%>
   <tr>
        <th>Total</th>
        <th><%= total %></th>
   </tr>             
</table>

由于某些奇怪的原因,我无法将信息显示为网格(没有任何插件,只有 css)。

table
{
    border-collapse: separate;
    border-spacing: 2px;
    margin-top: 0.75em;
    border: 2px;
}

th
{
    font-size: 0.85em;
    text-align: left;
    padding-left: 0;
}

我对这项技术比较陌生,我怎样才能干净、独立地展示它?

编辑:

这或多或少是我想要的最终显示(没有背景色)

enter image description here

编辑2:

通过直接在代码中处理这种表格样式,我已经非常接近我想要的东西(我知道这通常不是一个好主意)。通过在需要的地方添加 style="border:1px solid;",可以显示网格。

最佳答案

您只在 CSS 文件中指定了边框的宽度。您还应该指定 border-style 属性,以便显示它。

例如:

border: 1px solid black;

颜色(在我的示例中为黑色)是可选的,但您可以使用简写形式将其与其他属性一起指定。

另见 this MDN article关于在 CSS 中指定边框。

关于html - <table> 样式元素未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33363420/

相关文章:

c# - 在MVC4中,如何一次保存多行编辑?

html - 让一长行字符在 HTML 中换行

javascript - 将 jQuery 集成到 Electron 应用程序中

javascript - 仅在页面加载后调用 JavaScript 中的函数

html - CSS - 一般说明

javascript - 我怎样才能在 php 中弹出图片?

javascript - Zurb 披萨饼图越来越大

html - 如何控制父 div 中子 div 的换行位置?

javascript - Ajax post 不向 MVC Controller 传递任何数据

.net - 仅具有 Entity Framework 代码和 ASP.NET MVC 的模块化应用程序