是否有可能有跨整个表行的背景渐变?我只能将背景应用于单独的表格单元格,即使我特意设法防止这种情况。这是一个在jsfiddle上针对Webkit的一个纯化示例:
正如你所看到的,我使用的是border-collapse:collapse,我指定了background:对于< tr>和< th>子元素,但是对于每个表格单元重复左侧的红色渐变。我已经尝试将背景应用到< tr>而且,与现在看到的结果相同。
要查看代码而不去jsfiddle,这里是:
HTML
- <table>
- <thead>
- <tr>
- <th>One</th>
- <th>Two</th>
- <th>Three</th>
- <th>Four</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>un</td>
- <td>deux</td>
- <td>trois</td>
- <td>quatre</td>
- </tr>
- </tbody>
- </table>
CSS
- * {margin:0;padding:0;border:0;border-collapse:collapse;}
- table { width:100%; }
- thead { background: -webkit-linear-gradient(left,rgba(222,22,1) 0%,222,0) 20%,0) 80%,1) 100%); }
- thead tr,thead th { background:transparent; }
解决方法
设置背景附件:固定;在那里,它会正常工作