首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

我可以创建一个HTML表宽度百分比高度但像素精确行高吗?

当然可以。您可以使用CSS来设置HTML表格的宽度为百分比,并且设置行高为像素精确值。以下是一个简单的示例:

代码语言:html
复制
<!DOCTYPE html>
<html>
<head><style>
table {
  width: 50%;
  border-collapse: collapse;
}

table, th, td {
  border: 1px solid black;
}

th, td {
  padding: 15px;
  text-align: left;
}

th {
  background-color: #f2f2f2;
}

tr:nth-child(even) {
  background-color: #f2f2f2;
}

tr:hover {
  background-color: #ddd;
}

th {
  height: 50px;
}

td {
  height: 100px;
}
</style>
</head>
<body><table>
  <tr>
    <th>Header 1</th>
    <th>Header 2</th>
  </tr>
  <tr>
    <td>Row 1, Cell 1</td>
    <td>Row 1, Cell 2</td>
  </tr>
  <tr>
    <td>Row 2, Cell 1</td>
    <td>Row 2, Cell 2</td>
  </tr>
</table>

</body>
</html>

在这个示例中,我们设置了表格的宽度为50%,并且设置了表头和单元格的行高。您可以根据需要调整这些值。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

没有搜到相关的沙龙

领券