gpt4 book ai didi

html - 在不切断右侧的情况下打印宽 HTML 表格

转载 作者:太空狗 更新时间:2023-10-29 13:14:24 25 4
gpt4 key购买 nike

我知道这个问题已经在这里多次出现,但我还没有找到专门解决我的问题的答案。我有一个要打印的表格,它有 16 列宽。当然,右侧只是在每个浏览器中被切断。我正试图找出一种方法来防止这种情况发生。最下面是样表,打印出来试试,右边被剪掉了。不幸的是,我无法执行以下选项:

  • 强制横向模式
  • 使用 word-break:break-all。就是不好看

理想情况下,我只想让表格占据所需的宽度,如果内容太多,则只需将其正常包装,以便单词中的字母保持在一起。

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body {
font-size: 12pt;
font-family: Garamond, Serif;
}
table {
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 15px;
font-size: 1.2em;
}
td, th {
padding: 2px 2px 2px 5px;
border: 1px solid #000000;
}
tr.tableTitle {
font-size: 1.2em;
font-weight: bold;
text-align: center;
background: #d0d0d0;
}

thead tr {
font-weight: bold;
background: #f0f0f0;
text-align: center;
}
button.expander {
border: 1px solid black;
border-radius: 5px;
color: black;
font-family: Verdana, Serif;
font-size: 1em;
font-weight: bold;
cursor: pointer;
float: left;
margin: 0px 5px 10px 0px;
background: #ffffff;
}
@media print {
button.expander{
display: none;
margin: 0px;
}
}
</style>
</head>
<body>

<div class="section">
<button class="expander">-</button>
<table>
<thead>
<tr class="tableTitle"><th colspan="16">Table Header</th></tr>
<tr>
<th>Column A</th>
<th>Column B Column B Column B</th>
<th>Column C</th>
<th>Column D</th>
<th>Column E</th>
<th>Column F</th>
<th>Column G Column G</th>
<th>Column H</th>
<th>Column I</th>
<th>Column J</th>
<th>Column K</th>
<th>Column L</th>
<th>Column M</th>
<th>Column N</th>
<th>Column O</th>
<th>Column P</th>
</tr>
</thead>
<tbody>
<tr>
<td>Column text here Column text here </td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
<td>Column text here Column text here</td>
</tr>
</tbody>
</table>
</div>

</body>
</html>

HTML View

Print View

最佳答案

您可以使用视口(viewport)的强大功能。检查Here信息

@media print 你的表格样式需要像这样

table{
font-size:1vw;
}

FIDDLE - DEMO PAGE FOR FIDDLE

关于html - 在不切断右侧的情况下打印宽 HTML 表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23296872/

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