如何让表格单元格具有相同的高度?检出http://thomaswd.com/organizer/dashboard并点击日历。你会看到表格单元格有不同的高度。我有两排固定高度的桌子顶部,我的桌子高度是100%。我不想要指定的像素高度,因为浏览器调整大小时不起作用。我该怎么做呢?如何让表格单元格具有相同的高度
回答
为了让表细胞具有相等的高度我用谷歌Chrome和检查通过在日历上右键单击并选择“检查元素”,可以选择日历中的某一天。然后,我改变了'calendar-day'的样式,如下所示:
/* shared */
td.calendar-day, td.calendar-day-np {
border-bottom:1px solid #999;
border-right:1px solid #999;
height: 10%;
}
只需在style.css中指定想要的高度即可。
什么是百分比'高度:10%;'出了什么?如果我有十多行? – Flimm 2015-02-06 16:01:45
由于这是一个表格单元,高度将超出表格的高度。 – 2015-05-31 18:09:52
来源:How can I force all rows in a table to have the same height
<html>
<head>
<style type="text/css">
#fixedheight {
table-layout: fixed;
}
#fixedheight td {
width: 25%;
}
#fixedheight td div {
height: 20px;
overflow: hidden;
}
</style>
</head>
<body>
<table id="fixedheight">
<tbody>
<tr>
<td><div>content</div></td>
<td><div>lots of content that should spend way more time wrapping down than it should if I were just to have a short bit of stuff, that would be invaded by zombies and the such</div></td>
<td><div>more content</div></td>
<td><div>small content</div></td>
<td><div>enough already</div></td>
</tr>
</tbody>
</table>
</body>
</html>
我不想固定高度 – 2013-03-13 22:48:05
显然适应脚本到您的表格尺寸... – 2013-03-13 22:48:52
然后使用百分比,而不是固定高度?从个人调整你的桌子的大小,我会添加一个最小尺寸和其他隐藏以及! – 2013-03-13 22:51:10
看起来你想要的是最高的单元格的高度,以在该行中传播。
您可以用JavaScript做到这一点:
var eq_el_height = function(els, min_or_max) {
els.each(function() {
$(this).height('auto');
});
var m = $(els[0]).height();
els.each(function() {
var h = $(this).height();
if (min_or_max === "max") {
m = h > m ? h : m;
} else {
m = h < m ? h : m;
}
});
els.each(function() {
$(this).height(m);
});
};
通过你的表格单元格到这样的功能:
$(#fixedheight tr').each(function(){
eq_el_height($(this).find('td'), "max");
});
作品像一个魅力 – mwallisch 2016-12-01 20:53:47
谢谢你救了我的一天! – SalutonMondo 2017-02-14 14:34:56
另一种解决方案可以是:
var maxHeight = null;
$('#tableId tr').each(function() {
var thisHeight = $(this).height();
if(maxHeight == null || thisHeight > maxHeight) maxHeight = thisHeight;
}).height(maxHeight);
- 1. 如何显示:表格单元格与我的CSS具有相同的高度?
- 2. 如何设置表格标题单元格与列具有相同的宽度?
- 3. 表格单元格高度
- 4. 表格:行中单元格的高度相同
- 5. 具有不同单元高度的HTML表格行
- 6. 如何让表格标题不同高度互相之间?
- 7. 如何让div占用不具有固定TD高度的html表格单元高度的100%?
- 8. HTML表格 - 如何让子表格的列具有与父表格列相同的宽度?
- 9. 如何让两个div具有相同的高度和宽度?
- 10. 如何让div具有相同的内容宽度和高度?
- 11. 如何在Knockoutjs中合并具有相同内容的表格单元格?
- 12. 列中的单元格不具有相同的宽度
- 13. jQTouch动画表格单元格高度
- 14. IE8拉伸表格单元格高度
- 15. 最小高度和表格单元格
- 16. 具有相同高度和表格风格的流体布局div
- 17. 如何获取C#中itextSharp表格单元格的高度?
- 18. 如何在表格单元格内设置100%的div高度
- 19. 如何让所有的HTML元素具有相同的宽度?
- 20. 如何让布局具有相同的高度?
- 21. 如何datagrid单元格工具提示大小(高度/宽度)?
- 22. 计算具有相同背景颜色的单元格列表
- 23. 如何让锚点不超过表格单元格宽度?
- 24. 显示:所有单元格的表格单元格相同空间
- 25. CSS表格,Firefox中表格单元格高度问题
- 26. Firefox,CSS显示:表格/表格单元格和高度
- 27. 如何获取具有不同单元类别的单元格
- 28. IOS UICollectionView单元格具有不同的单元格实例
- 29. Three20 TTTableViewController单元格高度
- 30. 选择一个表格单元格并让多个单元格瞬间高亮
可以使用相对高度为好,例如10% – Horen 2013-03-13 22:45:14
是的,但前2排有像素高度 – 2013-03-13 22:45:55