html - Chrome 中表格标题的框阴影

标签 html css

我正在尝试将 box-shadow 添加到表格的第一行(标题), 这在 Firefox 中运行良好,但不幸的是在 Chrome 中不起作用。

我尝试过使用不同的显示属性值(例如“display: block”), 它在 Chrome 中添加了阴影,但将整个标题移动到第一列的第一个单元格中。关于如何在我的案例中添加 box-shadow 的任何解决方案?

下面是我的 CSS/HTML 示例(box-shadow 与选择器“tr:first-child”一起使用):

body,
html {
  height: 100%;
  background-color: #E0E0E0;
}
table {
  margin-left: auto;
  margin-right: auto;
  margin-top: 10px;
  margin-bottom: 25px;
  background: linear-gradient(to bottom, #E0E0E0 0%, #E1E1E1 10%, #E5E5E5 47%, #E7E7E7 100%);
  -webkit-border-radius: 10px 10px 10px 10px;
  -moz-border-radius: 10px 10px 10px 10px;
  border-radius: 10px 10px 10px 10px;
  box-sizing: border-box;
}
table,
th,
td {
  border-collapse: collapse;
}
tr:hover {
  background-color: #E0E0E0;
}
tr:first-child {
  background-color: #E0E0E0;
  -webkit-border-radius: 10px 10px 10px 10px;
  -moz-border-radius: 10px 10px 10px 10px;
  border-radius: 10px 10px 10px 10px;
  -webkit-box-shadow: 3px 5px 10px grey;
  -moz-box-shadow: 3px 5px 10px grey;
  box-shadow: 3px 5px 10px grey;
}
th {
  background-color: #404040;
  color: #FFFFFF;
}
th,
td {
  padding: 3px;
  max-width: 600px;
}
td {
  border-bottom: 1px solid #909090;
}
td.last_row {
  border-bottom: none;
}
td:first-child {
  text-align: center;
  width: 25px;
}
td:last-child {
  text-align: center;
  width: 50px;
}
#column_1 {
  -webkit-border-radius: 10px 0px 0px 10px;
  -moz-border-radius: 10px 0px 0px 10px;
  border-radius: 10px 0px 0px 10px;
}
#column_2 {
  -webkit-border-radius: 0px 10px 10px 0px;
  -moz-border-radius: 0px 10px 10px 0px;
  border-radius: 0px 10px 10px 0px;
}
.outer_col {
  border: none;
}
<body>
  <table>
    <tr>
      <th id="column_1">ID</th>
      <th id="column_2" colspan="2">DESCRIPTION</th>
    </tr>
    <tr>
      <td class="outer_col">1</td>
      <td>Lorem ipsum dolor sit amet, consectetur adipiscing elit</td>
      <td class="outer_col"><a href="#">Link</a>
      </td>
    </tr>
    <tr>
      <td class="outer_col">2</td>
      <td>Lorem ipsum dolor sit amet, consectetur adipiscing elit</td>
      <td class="outer_col"><a href="#">Link</a>
      </td>
    </tr>
    <tr>
      <td class="outer_col">3</td>
      <td class="last_row">Lorem ipsum dolor sit amet, consectetur adipiscing elit</td>
      <td class="outer_col"><a href="#">Link</a>
      </td>
    </tr>
  </table>
</body>

最佳答案

把你的盒子阴影效果移到:

th {
  background-color: #404040;
  color: #FFFFFF;
  -webkit-border-radius: 10px 10px 10px 10px;
  -moz-border-radius: 10px 10px 10px 10px;
  border-radius: 10px 10px 10px 10px;
  -webkit-box-shadow: 3px 5px 10px grey;
  -moz-box-shadow: 3px 5px 10px grey;
  box-shadow: 3px 5px 10px grey;
}

tr:first-child 与您的情况下的 th 相同,因此您不需要它。

要使其在最新版本的 IE 中工作,您需要添加以下内容: 边界折叠:分开;

关于html - Chrome 中表格标题的框阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31810634/

相关文章:

css - 在鼠标悬停时显示背景图像

javascript - 一键-两种功能

html - 填充和文本 - 被剪切的文本

javascript - Css - 是否可以在调整屏幕大小时移动元素以使其适合屏幕

javascript - 如何为我的 SVG 路径设置动画

html - div css 左上角不工作

css - 在 IE 中更改 TinyMCE 表的边框颜色

jquery - 如何使用 Bootstrap 创建无边框表格

jQuery:第一级 li 标签的计数(不包括 decendent ul > li 标签)

html - Bootstrap 位置菜单右上角