我有一个小小的网页:
这是源代码:
<head>
<meta charset="UTF-8">
<style>
body {
margin-left: 20px;
margin-top: 20px;
}
h1 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h2 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h3 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h4 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h5 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h6 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
hr {
height: 3px;
border-radius: 2px;
border-width: 0;
color: lightgray;
background-color: lightgray;
}
.button {
display: inline-block;
background-color: darkgray;
color: white;
text-decoration: none;
border-radius: 2px;
padding: 6px;
margin-left: 2px;
margin-right: 2px;
}
.button:hover {
color: black;
}
.button:visited {
color: white;
}
.button:active {
color: white;
}
a {
color: gray;
}
</style>
</head>
<body nyxt-identifier="0">
<style nyxt-identifier="1">
body {
margin-left: 20px;
margin-top: 20px;
}
h1 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h2 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h3 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h4 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h5 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
h6 {
font-family: Helvetica Neue, Helvetica;
font-weight: 500;
}
hr {
height: 3px;
border-radius: 2px;
border-width: 0;
color: lightgray;
background-color: lightgray;
}
.button {
display: inline-block;
background-color: darkgray;
color: white;
text-decoration: none;
border-radius: 2px;
padding: 6px;
margin-left: 2px;
margin-right: 2px;
}
.button:hover {
color: black;
}
.button:visited {
color: white;
}
.button:active {
color: white;
}
a {
color: gray;
}
</style>
<h1 nyxt-identifier="2">Bindings</h1>
<p nyxt-identifier="3">
</p>
<div nyxt-identifier="4">
<h3 nyxt-identifier="5">override-map</h3>
<table nyxt-identifier="6">
<tbody nyxt-identifier="7">
<tr nyxt-identifier="8">
<td nyxt-identifier="9">C-S
</td>
<td nyxt-identifier="10">search-buffers
</td>
</tr>
<tr nyxt-identifier="11">
</td>
</tr>
</tbody>
</table>
</div>
<div nyxt-identifier="44">
<h3 nyxt-identifier="45">web-cua-map</h3>
<table nyxt-identifier="46">
<tbody nyxt-identifier="47">
<tr nyxt-identifier="48">
<td nyxt-identifier="49">f3
</td>
<td nyxt-identifier="50">search-buffer
</td>
</tr>
<tr nyxt-identifier="51">
</td>
</tr>
</tbody>
</table>
</div>
<div nyxt-identifier="195">
<h3 nyxt-identifier="196">base-cua-map</h3>
<table nyxt-identifier="197">
<tbody nyxt-identifier="198">
<tr nyxt-identifier="199">
<td nyxt-identifier="200">f5
</td>
<td nyxt-identifier="201">reload-current-buffer
</td>
</tr>
<tr nyxt-identifier="202">
</td>
</tr>
</tbody>
</table>
</div>
</body>
上面的代码和图像是对实际问题的简化。在实际问题中,页面要大得多,因为表中的元素比当前显示的要多。
我想以更好的方式利用空间,这样打印它就不会花费太多的纸张。屏幕右侧浪费了很多空间。
内容可以在水平方向上更广泛地传播,而不是只在垂直方向上传播。
实现这一目标的两种可行的方法是(i)减少字体大小和(ii)使表格成为2列表格或3列而不是1列。
好的。我可以用CSS减少字体大小:
tr { font-size: 10px}
因此,我想问:
1 -如何使表是3列或2列表使用CSS?
我按照W3C的例子尝试了这种方法:
table {
column-span: all;
}
但这并没有成功。
2 -除了字体和列号的调整,你还有什么建议可以最大限度地利用空间和减少用纸吗?
这一点都不复杂。您只需将所有的键绑定和标题放在一个表中,而不是每个键绑定和标题都放在它自己的表中。然后,我们使用一点CSS来在表格单元格之间得到一个小的边框线——如果你不想要边框,只需删除CSS部分。是这样的:
table {
border-spacing: 0;
}
td {
border: 1px solid black;
padding: 10px;
}
<h1>Bindings</h1>
<table>
<tbody>
<tr>
<td colspan="2">
override-map
</td>
<td colspan="2">
web-cua-map
</td>
<td colspan="2">
base-cua-map
</td>
</tr>
<tr>
<td>
C-S
</td>
<td>
search-buffers
</td>
<td>
F3
</td>
<td>
search-buffer
</td>
<td>
F5
</td>
<td>
reload-current-buffer
</td>
</tr>
</tbody>
</table>