html - 在 td 中使用 div 固定表格行高

标签 html css html-table row

我有一张 table 。有些 td 是空的,有些看起来像这样:

<td><div class='divintd'>+</div></td>

具有非空 td 的行会调整其高度和宽度。我从 StackOverflow 存档中发现,将 td 放在 div 中是唯一的选择。我实现了此处建议的代码:How to fix height of TR? , 但我的 table 还是搞砸了。我做错了什么,我该如何解决? CSS:

table td {
    width: 4px;
    height: 4px;
}

.divintd {
    width: 100%; 
    height: 100%; 
    max-height: 100%;
    max-width: 100%;
    overflow: hidden;
}

最佳答案

第一个变化

<td><div class='divintd'>+</div></td>

进入

<div class='divintd'><td>+</td></div> 

.divintd td {
    width: 100%; 
    height: 100%; 
    max-height: 100%;
    max-width: 100%;
    overflow: hidden;
}

关于html - 在 td 中使用 div 固定表格行高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23196371/

相关文章:

jquery - 如何显示基于 Html.DropDownList 的 div?

php - 如何在页面底部添加页脚 wkhtmltopdf

javascript,仅在满足特定条件时才更改类

html - CSS div 的尺寸为 NaN

javascript - 从 JavaScript 更改 HTML5 视频的质量

Jquery 加载页面覆盖我的 CSS

html - 如何在 html/css 中定位适合移动浏览器的图像

php - 将 SQL 数据放入 HTML 表

css - 单元格中表格的文本对齐(<table> 内的 <td>)

javascript - javascript 中有合并或拆分表格单元格的完整示例吗?