合并 HTML 中的单元格
Merge cells in HTML
我正在尝试在 HTML 中执行 table,但我遇到了问题。不知道如何去做我要解释的事情:
我是否可以将一个 below/adjoined 的单元格转换为另一个具有长垂直文本的单元格,并将其转换为小方形格式,而无需从其正上方的单元格中占用相同的长垂直文本格式?
这是 HTML 文档:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Marge Cells</title>
<link rel="stylesheet" type="text/css" href="dudas.css">
</head>
<body>
<table border="1px">
<tr>
<td>
</td>
<td class="Rotate-90">
corto
</td>
<td class="Rotate-90">
text muuuuy largo
</td>
</tr>
<tr>
<td>
Cuentas
</td>
<td>
11.2€
</td>
<td>
1€
</td>
</tr>
</table>
</body>
</html>
这里是 CSS:
@charset "UTF-8";
.Rotate-90
{
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
-webkit-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
-ms-transform-origin: 50% 50%;
-o-transform-origin: 50% 50%;
transform-origin: 50% 50%;
position:relative;
height: 15px;
width: 30 px;
}
table {
border-collapse: collapse;
}
这是我要实现的目标的图片
--- 新 ---
现在我明白你了..
.table-r {
border-collapse: collapse;
}
.table-r td {
width: 30px;
}
..table-r th {
padding: 5px 10px;
}
.table-r td {
text-align: center;
padding: 10px 5px;
border: 1px solid #ccc;
}
.table-r th.th-r {
height: 140px;
white-space: nowrap;
}
.table-r th.th-r > div {
transform: translate(25px, 51px) rotate(315deg);
width: 30px;
}
.table-r th.th-r > div > span {
border-bottom: 1px solid #ccc;
padding: 5px 10px;
}
.table-header-rotated th.row-header {
padding: 0 10px;
border-bottom: 1px solid #ccc;
}
<table class="table-r">
<thead>
<tr>
<th class="th-r">
<div><span>Header 1</span>
</div>
</th>
<th class="th-r">
<div><span>Header 2</span>
</div>
</th>
<th class="th-r">
<div><span>Header 3</span>
</div>
</th>
<th class="th-r">
<div><span>Header 4</span>
</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
</tr>
<tr>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
</tr>
</tbody>
</table>
---老---
这是你的意思吗?
.Rotate-90 {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
-webkit-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
-ms-transform-origin: 50% 50%;
-o-transform-origin: 50% 50%;
transform-origin: 50% 50%;
position: relative;
height: 15px;
width: 30 px;
}
table {
border-collapse: collapse;
}
<table>
<tr>
<th rowspan="4" class="Rotate-90">text vertical</th>
<th>2</th>
<th>3</th>
<th>4</th>
</tr>
<tr>
<td>4</td>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>10</td>
<td>11</td>
<td>12</td>
</tr>
<tr>
<td>14</td>
<td>15</td>
<td>16</td>
</tr>
</table>
您有 rowspan 和 colspan。
colspan 这样做:
+-------------------+
| 1 |
+-------------------+
| 3 | 4 | 7 | 8 |
+----+----+----+----+
| 9 | 10 | 11 | 12 |
+----+----+----+----+
| 13 | 14 | 15 | 16 |
+----+----+----+----+
rowspan 这样做:
+----+----+----+----+
| 1 | 2 | 3 | 4 |
+ +----+----+----+
| | 4 | 7 | 8 |
+ +----+----+----+
| | 10 | 11 | 12 |
+ +----+----+----+
| | 14 | 15 | 16 |
+----+----+----+----+
Rowspan 和 Colspan 合并:
+---------+----+----+
| 1 | 3 | 4 |
+ +----+----+
| | 7 | 8 |
+---------+----+----+
| 9 | 10 | 11 | 12 |
+----+----+----+----+
| 13 | 14 | 15 | |
+----+----+----+----+
我正在尝试在 HTML 中执行 table,但我遇到了问题。不知道如何去做我要解释的事情:
我是否可以将一个 below/adjoined 的单元格转换为另一个具有长垂直文本的单元格,并将其转换为小方形格式,而无需从其正上方的单元格中占用相同的长垂直文本格式?
这是 HTML 文档:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Marge Cells</title>
<link rel="stylesheet" type="text/css" href="dudas.css">
</head>
<body>
<table border="1px">
<tr>
<td>
</td>
<td class="Rotate-90">
corto
</td>
<td class="Rotate-90">
text muuuuy largo
</td>
</tr>
<tr>
<td>
Cuentas
</td>
<td>
11.2€
</td>
<td>
1€
</td>
</tr>
</table>
</body>
</html>
这里是 CSS:
@charset "UTF-8";
.Rotate-90
{
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
-webkit-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
-ms-transform-origin: 50% 50%;
-o-transform-origin: 50% 50%;
transform-origin: 50% 50%;
position:relative;
height: 15px;
width: 30 px;
}
table {
border-collapse: collapse;
}
这是我要实现的目标的图片
--- 新 ---
现在我明白你了..
.table-r {
border-collapse: collapse;
}
.table-r td {
width: 30px;
}
..table-r th {
padding: 5px 10px;
}
.table-r td {
text-align: center;
padding: 10px 5px;
border: 1px solid #ccc;
}
.table-r th.th-r {
height: 140px;
white-space: nowrap;
}
.table-r th.th-r > div {
transform: translate(25px, 51px) rotate(315deg);
width: 30px;
}
.table-r th.th-r > div > span {
border-bottom: 1px solid #ccc;
padding: 5px 10px;
}
.table-header-rotated th.row-header {
padding: 0 10px;
border-bottom: 1px solid #ccc;
}
<table class="table-r">
<thead>
<tr>
<th class="th-r">
<div><span>Header 1</span>
</div>
</th>
<th class="th-r">
<div><span>Header 2</span>
</div>
</th>
<th class="th-r">
<div><span>Header 3</span>
</div>
</th>
<th class="th-r">
<div><span>Header 4</span>
</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
</tr>
<tr>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
</tr>
</tbody>
</table>
---老--- 这是你的意思吗?
.Rotate-90 {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
-webkit-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
-ms-transform-origin: 50% 50%;
-o-transform-origin: 50% 50%;
transform-origin: 50% 50%;
position: relative;
height: 15px;
width: 30 px;
}
table {
border-collapse: collapse;
}
<table>
<tr>
<th rowspan="4" class="Rotate-90">text vertical</th>
<th>2</th>
<th>3</th>
<th>4</th>
</tr>
<tr>
<td>4</td>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>10</td>
<td>11</td>
<td>12</td>
</tr>
<tr>
<td>14</td>
<td>15</td>
<td>16</td>
</tr>
</table>
您有 rowspan 和 colspan。
colspan 这样做:
+-------------------+
| 1 |
+-------------------+
| 3 | 4 | 7 | 8 |
+----+----+----+----+
| 9 | 10 | 11 | 12 |
+----+----+----+----+
| 13 | 14 | 15 | 16 |
+----+----+----+----+
rowspan 这样做:
+----+----+----+----+
| 1 | 2 | 3 | 4 |
+ +----+----+----+
| | 4 | 7 | 8 |
+ +----+----+----+
| | 10 | 11 | 12 |
+ +----+----+----+
| | 14 | 15 | 16 |
+----+----+----+----+
Rowspan 和 Colspan 合并:
+---------+----+----+
| 1 | 3 | 4 |
+ +----+----+
| | 7 | 8 |
+---------+----+----+
| 9 | 10 | 11 | 12 |
+----+----+----+----+
| 13 | 14 | 15 | |
+----+----+----+----+