gpt4 book ai didi

html - 具有交替行颜色的内部和外部边框

转载 作者:行者123 更新时间:2023-11-28 13:27:19 26 4
gpt4 key购买 nike

根据下面的当前 css 编码,我如何能够执行以下操作:

  1. 修复表格,使表格标题中只有 1px 实心 FFF 的内部边框。
  2. 修复表头,使缺少的右边框完整。
  3. 在表格标题后放置一个 1px 纯色 #6B6B6B 的顶部边框(因为它似乎丢失了,我不知道如何修复它,我也在使用 IE 9)
  4. 从第一行(不是表格标题)开始交替显示行颜色(白色),然后在第二行(灰色)。

我刚接触css,不熟悉高级编程。

这是一个 fiddle :http://jsfiddle.net/3CzbV/

<!DOCTYPE html>
<html>

<head>

<style type="text/css">
table {
border-collapse: collapse;
border: 1px solid #6B6B6B;
}
table th {
color: red;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#cccccc, endColorstr=#ffffff);
}
table td {
color: blue;
}
table td, table th {
border: 1px solid #6B6B6B;
}
table tr:first-child th {
border-top: 0;
}
table tr:last-child td {
border-bottom: 0;
}
table tr td:first-child,
table tr th:first-child {
border-left: 0;
}
table tr td:last-child,
table tr th:last-child {
border-right: 0;
}
</style>

</head>

<body>

<table>
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
<th>Heading 3</th>
<th>Heading 4</th>
</tr>
<tr>
<td>Cell (1,1)</td>
<td>Cell (2,1)</td>
<td>Cell (3,1)</td>
<td>Cell (4,1)</td>
</tr>
<tr>
<td>Cell (2,1)</td>
<td>Cell (2,2)</td>
<td>Cell (3,2)</td>
<td>Cell (4,2)</td>
</tr>
<tr>
<td>Cell (3,1)</td>
<td>Cell (2,3)</td>
<td>Cell (3,3)</td>
<td>Cell (4,3)</td>
</tr>
</table>

</body>

</html>

最佳答案

首先你应该添加 <thead><tbody>元素/标签,甚至可能是 <tfoot>

HTML 标记

<div>
<table>
<thead>
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
<th>Heading 3</th>
<th>Heading 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell (1,1)</td>
<td>Cell (2,1)</td>
<td>Cell (3,1)</td>
<td>Cell (4,1)</td>
</tr>
<tr>
<td>Cell (2,1)</td>
<td>Cell (2,2)</td>
<td>Cell (3,2)</td>
<td>Cell (4,2)</td>
</tr>
<tr>
<td>Cell (3,1)</td>
<td>Cell (2,3)</td>
<td>Cell (3,3)</td>
<td>Cell (4,3)</td>
</tr>
</tbody>
</table>
</div>

风格

div{
background-color: grey;
margin: 20px;
padding: 10px;
}

table {
border-collapse: collapse;
border: 1px solid #6B6B6B;
margin: 20px;
}

/* 1.Fix the table such that there is an INNER border only of 1px solid FFF in the table headers*/
/* 2.Fix the table header such that the missing right border is completed */

table thead tr th {
border: 1px solid #FFF;

/* 3.Put a top border of 1px solid #6B6B6B after the table headers */
border-bottom: 1px solid #6B6B6B;
}

table tbody tr:nth-child(odd) {
background-color: white;
}

Fiddle

关于html - 具有交替行颜色的内部和外部边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13211425/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com