html - 如何在边缘隐藏表格行和列?
问题描述
例如,我有一个 82x82 的表。但我只想显示表格的中央 80x80 部分。隐藏的表格单元格仍然有一些数据,我只是不想显示它们。我的想法是将表格放入一个 div 中,以隐藏表格中不必要的部分。像这样:
#workspace {
position: absolute;
width: 800px;
height: 800px;
top: 50%;
left: 50%;
margin-left: -400px;
margin-top: -400px;
overflow: hidden;
}
table {
position: absolute;
margin-left: -10px;
margin-top: -10px;
width: 820px;
height: 820px;
}
<div id="workspace">
<table>
</table>
</div>
但是当我在 Mozilla 中打开控制台时,我看到了隐藏单元格的一部分(见表格底部):
所以我的问题是如何解决这个问题?或者也许建议我用其他方法来隐藏表格中不必要的部分?
PS表格单元格是用javascript创建的
解决方案
使用nth-child()
选择器获取和隐藏边缘的表格元素。
tr:first-child,
tr:last-child,
td:first-child,
td:last-child {
display: none
}
推荐阅读
- python - 在 django webapp 中使用 jquery 和 AJAX 自动完成搜索
- python - 返回所有值包含python字典中的特定文本
- git - 从服务器端目录恢复 GitLab 存储库
- c++ - SIMD __m256i 到 __m256d 转换结果
- java - 从 Java 字符串中提取值
- mysql - 如果密钥对存在于另一个表中,则选择列为真/假
- c++ - Boost 1.69 中的某些库是否与 MacOS 不兼容?
- python-3.x - PyQt5 & PySide2 / 无法在“”中加载 Qt 平台插件“windows”,即使它被发现
- python - 在 Matplotlib 中为 Boxplot 提供自定义四分位数范围
- couchdb - 自定义 CouchDb SSL 证书验证