there is a table frame about header, footer and body, I take it through table,
I indicate height of head & footer with class theader(100px) & tfooter(50px),
and keep tbody height empty to program auto calc the remain height.
last, I add a div as container and provider scroll when content out of height.
I get the result success with IE 6, chrome 12, safari 5.0.3,
but failure in FF 6.0
<html>
<head>
<title>table 100% height</title>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#t {
table-layout: fixed;
border-collapse: collapse;
height: 100%;
width: 100%;
}
#t td {
border: 1px solid #777;
}
.theader {
height: 100px;
text-align: center;
}
.tbody {
}
.tfooter {
height: 50px;
text-align: center;
}
</style>
</head>
<body>
<table id="t">
<tr>
<td class="theader">
<div style="border: 0px solid #666; height: 100%; overflow: auto;">
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
</div>
</td>
</tr>
<tr>
<td class="tbody">
<div style="height: 100%; overflow: auto;">
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
</div>
</td>
</tr>
<tr>
<td class="tfooter">
<div style="height: 100%; overflow: auto">
footer<br />
footer<br />
footer<br />
footer<br />
footer<br />
footer<br />
</div>
</td>
</tr>
</table>
</body>
</html>
result IE 6
result Chrmoe 12
result Safari 5.0.3
result FF6
look at the result of FF6, the height of td of tbody, can't keep it's original height(the remain height after header & footer), it's auto markup the height to fit td's content. and add scroll to body
it's not what I want. to fix this issue, I try to special a value to td height.
it work, but it's not a good method. because I can't know client browser availHeight. and I can't calc the remain height every time.
it's occur in FF6.0 only, it's work correctly in IE6, chrome12, safari.
2011-09-11
new understand:
as standard model does not support 100% height div nested in td in fact,
so it's render by quirk model, it's mean: it's decide by browser, so, IE and chrome consider this issue and compatible it. but maybe FF stand to w3c stand,
so does not support this issue.
and FF prepare an other solution to solve it: position fixed, a property indicate element locale by window;
<html>
<head>
<title>div width fix, work in ie6, chrome, but without FF</title>
<style>
table {
table-layout: fixed;
height: 100%;
width: 100%;
}
table td {
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<td height="50">
<div style="overflow: auto; width: 100%; height: 100%">
to solve the issue:<br />
"div width fix, work in ie6, chrome, but without FF<br />
div bottom will be broken when div height not enought for it's content"<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
header<br />
</div>
</td>
</tr>
<tr>
<td>
<!-- the below '' to show td border -->
<div style="border: 1px solid #777; position: fixed; top: 75px; right: 15px; bottom: 75px; left: 15px; overflow: auto">
<div style="border: 1px solid #ccc; width: 1000px;">
abc
</div>
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
abc<br />
</div>
</td>
</tr>
<tr>
<td height="50">
<div style="overflow: auto; height: 100%">
footer<br />
footer<br />
footer<br />
footer<br />
footer<br />
footer<br />
footer<br />
footer<br />
</div>
</td>
</tr>
</table>
</body>
</html>
it's work in FF, chrome, Mathon, except IE6
because IE6 do not support fixed in position
result as below:
----------------------------------------------------------------------
summary:
div 100% height nested in td
IE6 support
chrome support
FF not support
position fixed (css2)
IE6 not support
chrome support
FF support
- 大小: 78.6 KB
- 大小: 62.6 KB
- 大小: 53.8 KB
- 大小: 74.2 KB
- 大小: 83.2 KB
分享到:
相关推荐
"fixed header grid" 是一种网页设计技术,主要应用于数据表格,特别是当表格数据量较大时,需要保持表头(thead)在页面滚动时固定不动,以便用户在浏览长表格时始终能看清列名。这种技术通常结合 JavaScript 库,...
Bootstrap表格在设计网页时是一种非常常用的组件,尤其在处理大量数据时,为了提供更好的用户体验,我们经常需要在tbody部分添加竖向滚动条,同时保持表头固定不动。这样,当用户滚动内容时,表头始终保持可见,便于...
This is yet another jQuery plugin to provide fixed headers for tables. It differs in the way that it does not require any odd html table semantics. It just needs a TABLE tag with THEAD and TBODY to ...
<TD width="95%" height=1216> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY> <TR> <TD colSpan=2> border=0> <TBODY> <TR> <TD width="19%" background=/images/index_24.jpg ...
<td height="5" width="491"> </td> <td width="10" height="5"> </td> <td height="5" width="487"> </td> </tr> <tr> <td id="top" ...
<TD align=left width=98 height=30><strong><font color=#009933>¥98元</font></strong></TD></TR></TBODY></TABLE></DIV></TD> <TD align=middle width=173 background=...
在使用table展示内容时,经常会出现内容过长超出了单元格(td)的宽度,导致无法完整展示全部内容的情况。传统的table布局常常会导致内容溢出,影响页面的整体美观性。本篇文章针对的就是这个常见的问题,即如何设置...
table固定左侧多列,画面中可对多个table进行固定,谷歌、ie都试过没问题;之前实在是网上找不到好的,就自己整合弄了一个,质量没的说,肯定胜过90%其他的;调用简单: ...(注:table中要含有thead、tbody)
for header in header_cells: print(header.text) # 处理表体 body_rows = tbody.find_elements_by_tag_name('tr') for row in body_rows: data_cells = row.find_elements_by_tag_name('td') for cell in ...
tbody元素支持嵌套的注意方法 在HTML中,tbody元素是table元素的一个子元素,用于定义表格的主体部分。tbody元素可以嵌套其他元素,如tr、td等,以便创建复杂的表格结构。但是,在使用tbody元素时需要注意一些方法...
<thead> … </thead> – 表的题头(Header) <tbody> … </tbody> – 表的正文(Body) <tfoot> … </tfoot> – 表的脚注(Footer) 例: <table> <thead> <tr><th>Food</th><th>Drink</th><th>Sweet</th></tr> </thead> ...
<TBODY> <TD colSpan=4> </TD> <TR height=30> <TD width=380> </TD> <TD> </TD> <TD> </TD> <TD> </TD> <TR height=40> <TD rowSpan=4> </TD> <TD>用户名:...
表格的分组显示(Structured Table) (IExplore Only) 1)按行分组 <thead> … </thead> – 表的题头(Header) <tbody> … </tbody> – 表的正文(Body) <tfoot> … </tfoot> – 表的脚注(Footer) 例: <table> ...
#fixed-header-table th, #fixed-header-table td { border: 1px solid #ddd; padding: 8px; } #fixed-header-table tbody { display: block; overflow-y: auto; height: 200px; /* 设置表格内容区域的高度 */...
/* 第一种,原生的js,先获取table然后获取tr标签,然后遍历td */ // $('#selectIds').val(); // var table = document.getElementById(tb_table);//获取第一个表格 // var array = table.getElementsByTagName(tr...
table表格,让thead固定,tbody有滚动条,关键是都对齐的纯css写法。table表格,让thead固定,tbody有滚动条,关键是都对齐的纯css写法。table表格,让thead固定,tbody有滚动条,关键是都对齐的纯css写法。table...
例如,你可以通过"data-fixed-columns"`属性来设定需要固定的列数,然后通过"data-fixed-column-left"`或"data-fixed-column-right"`来指定固定在左侧或右侧的列数。 ```html <table id="fixedTable" data-toggle=...
$header.width($('table.fixed-header tbody').width()); }); // 初始化宽度 $header.width($('table.fixed-header tbody').width()); }); ``` **3. 文件解析** 在提供的压缩包文件中,我们有以下文件: - `...
... 1. 彩色字体色彩绚丽 ...例如:华文新魏><FONT color=#... HEIGHT: 51px">向上移动的文字</MARQUEE></DIV></TD></TR></TBODY> HTML动态字效果可以使用不同的HTML标签和CSS样式来实现,增强网页的视觉效果和用户体验。