如何将 table 从 html 完全复制到 MS Word?
How to get table fully copied from html to MS Word?
我正在尝试将 html
中的 table
从浏览器(在 Chrome 中工作)完全复制到 Word 文档。发生的情况是最后一行的边框没有在 Word 中传递。
取码:
HTML:
<table id="t6">
<tr><th></th><th>raw_alpha</th><th>std.alpha</th><th>G6(smc)</th><th>average_r</th></tr>
<tr><td>gse1</td><td>0.88</td><td>0.88</td><td>0.88</td><td>0.45</td></tr>
<tr><td>gse10</td><td>0.88</td><td>0.88</td><td>0.88</td><td>0.45</td></tr>
</table>
CSS:
table, th, tr, td {
background-color:white;
border-spacing: 0;
padding: 2px 6px;
border-collapse:collapse;
text-align: right;
}
th {
background-color: white;
color: black;
border-width:1px;
border-color: #000;
border-style: solid none solid none;
}
tr:last-child {
border: 1px solid #000;
border-style: none none solid none;
}
有没有办法让最后一行的边框包含在内?这也有可能在 Firefox 中工作吗?
应用于 tr
元素的边框显然无法识别,因此您需要将它们应用于 td
。
在您的 CSS 中,将 tr:last-child
更改为 tr:last-child td
,它应该可以工作。
我正在尝试将 html
中的 table
从浏览器(在 Chrome 中工作)完全复制到 Word 文档。发生的情况是最后一行的边框没有在 Word 中传递。
取码:
HTML:
<table id="t6">
<tr><th></th><th>raw_alpha</th><th>std.alpha</th><th>G6(smc)</th><th>average_r</th></tr>
<tr><td>gse1</td><td>0.88</td><td>0.88</td><td>0.88</td><td>0.45</td></tr>
<tr><td>gse10</td><td>0.88</td><td>0.88</td><td>0.88</td><td>0.45</td></tr>
</table>
CSS:
table, th, tr, td {
background-color:white;
border-spacing: 0;
padding: 2px 6px;
border-collapse:collapse;
text-align: right;
}
th {
background-color: white;
color: black;
border-width:1px;
border-color: #000;
border-style: solid none solid none;
}
tr:last-child {
border: 1px solid #000;
border-style: none none solid none;
}
有没有办法让最后一行的边框包含在内?这也有可能在 Firefox 中工作吗?
应用于 tr
元素的边框显然无法识别,因此您需要将它们应用于 td
。
在您的 CSS 中,将 tr:last-child
更改为 tr:last-child td
,它应该可以工作。