CSS边框不适用于表格

问题描述 投票:-2回答:2

当我运行应用程序时,我的CSS表上对表信息的更改似乎没有改变。 CSS主要是在我创建MVC时预先生成的。我只是希望表格有边框,所以我添加了“border:solid 2px black”部分。但它似乎没有添加边框。我在这做错了什么? CSS:

table {
  margin-top: 0.75em;
  border: solid 2px black;
}

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

th a {
  display: block;
  position: relative;
}

th a:link,
th a:visited,
th a:active,
th a:hover {
  color: #333;
  font-weight: 600;
  text-decoration: none;
  padding: 0;
}

th a:hover {
  color: #000;
}

th.asc a,
th.desc a {
  margin-right: .75em;
}

th.asc a:after,
th.desc a:after {
  display: block;
  position: absolute;
  right: 0em;
  top: 0;
  font-size: 0.75em;
}

th.asc a:after {
  content: '▲';
}

th.desc a:after {
  content: '▼';
}

td {
  padding: 0.25em 2em 0.25em 0em;
  border: 0 none;
}

tr.pager td {
  padding: 0 0.25em 0 0;
}
<table>
  <tr>
    <th>
      Project ID
    </th>
    <th>
      Test1
    </th>
    <th>
      Test2
    </th>
    <th>
      Test3
    </th>
    <th>
      Test4
    </th>
    <th>
      Test5
    </th>
  </tr>
</table>
css asp.net-mvc
2个回答
1
投票

我运行你的代码和表有边框!也许还有另一个违反你的风格的css代码,所以请使用!important

border: solid 2px black !important;

如果要边框每个单元格使用此代码

table, th, td {
border: 1px solid black;
border-collapse: collapse;}

0
投票

我发现了问题,而且非常愚蠢。我需要刷新缓存(Ctrl + F5)。它导致了改变的CSS。

© www.soinside.com 2019 - 2024. All rights reserved.