我试图使用JavaScript和CSS和HTML立式头,但头高度不动态获取调整,我想我做了一些错误的东西在呼唤JSS的JavaScript在CSS不工作
代码:
<style>
table, tr, td, th {
border: 1px solid #000;
position: relative;
padding: 10px;
}
th span {
transform-origin: 0 50%;
transform: rotate(-90deg);
white-space: nowrap;
display: block;
position: absolute;
bottom: 0;
left: 50%;
}
</style>
<Script>
$(function() {
var header_height = 0;
$('table th span').each(function() {
if ($(this).outerWidth() > header_height) header_height =
$(this).outerWidth();
});
$('table th').height(header_height);
});
</script>
<html onload="function()">
<table>
<thead>
<tr>
<th><span>DATE</span></th>
<th><span>ACCOUNTNAME</span></th>
</tr>
</thead>
<tbody>
<tr>
<TD class=AltLight align=left height="17" width="10%">2017/10/20</TD>
<TD class=AltLight align=left height="17" width="10%">USA</TD>
</tr>
</tbody>
</table>
</html>
所需的输出
DATE(垂直题为)帐户(垂直题为
20/10/2017美国
'outerWidth'或'outerHeight'? –
您在代码中使用jQuery。 jQuery不是在你的HTML .... –
如何将它们添加到HTML代码 –