根据不同分区中的其他表头高度调整表头高度
Resize Table Header height according to other Table Header height in different div
我在网页上创建了一个规范区域,就像我在JSFIDDLE
中显示的那样。我不明白如何使左div和右div表头高度相等,因为左div表头高度中的每个部分可能因右div表头中插入的字符而异。代码如下:
#maindiv {
float:left;
width:100%;
height:565px;
color:Black;
}
#leftdiv {
border:1px solid black;
margin-top:0px;
margin-left:5px;
float:left;
height:100%;
width:30%;
-webkit-box-flex:1;
}
#leftdiv table {
padding:5px;
font-size:22px;
}
#rightdiv {
border:1px solid black;
margin-top:0px;
float:left;
height:100%;
width:67%;
-webkit-box-flex:1;
}
#rightdiv table {
padding:5px;
font-size:22px;
}
<div id="maindiv">
<div id="leftdiv">
<table align="center" border="1">
<tr>
<th>Product Name</th>
</tr>
<tr>
<th>Size Available</th>
</tr>
<tr>
<th>Color Available</th>
</tr>
<tr>
<th>Product Description</th>
</tr>
<tr>
<th>Availability</th>
</tr>
</table>
</div>
<div id="rightdiv">
<table align="left" border="1">
<tr>
<th>Cell Phone</th>
</tr>
<tr>
<th>5.5,6.5</th>
</tr>
<tr>
<th>White, Red, Black, Silver, Gold</th>
</tr>
<tr>
<th>QWERTY Soft Keyboard (Google Keyboard and Swiftkey Pre-loaded), USB OTG Support, 24 Languages Support, Wi-Fi Direct, WLAN Support, Games, Vibrant</th>
</tr>
<tr>
<th>This product is not out of stock.</th>
</tr>
</table>
</div>
</div>
新答案
OP后来明确表示,他不能只做一张桌子。
使用JQuery匹配高度如何。虽然丑陋,但它很管用(我的人生故事)。
JSFiddle
修复表格布局:
table{
table-layout: fixed;
}
给每一行一个唯一的ID
<table align="center" border="1">
<tr>
<th id="leftrow1">Product Name</th>
</tr>
<tr>
<th id="leftrow2">Size Available</th>
</tr>
<tr>
<th id="leftrow3">Color Available</th>
</tr>
<tr>
<th id="leftrow4">Product Description</th>
</tr>
<tr>
<th id="leftrow5">Availability</th>
</tr>
</table>
匹配它们:
$("#leftrow1").height($("#rightrow1").height());
$("#leftrow2").height($("#rightrow2").height());
$("#leftrow3").height($("#rightrow3").height());
$("#leftrow4").height($("#rightrow4").height());
$("#leftrow5").height($("#rightrow5").height());
也许还有比这更优雅的东西,我很想看到。
旧答案
只需将两个表合并为一个表,如下所示:
<table align="center" border="1">
<tr>
<th>Product Name</th>
<td>Cell Phone<</td>
</tr>
<tr>
<th>Size Available</th>
<td>5.5,6.5</td>
</tr>
<tr>
<th>Color Available</th>
<td>White, Red, Black, Silver, Gold</td>
</tr>
<tr>
<th>Product Description</th>
<td>QWERTY Soft Keyboard (Google Keyboard and Swiftkey Pre-loaded), USB OTG Support, 24 Languages Support, Wi-Fi Direct, WLAN Support, Games, Vibrant</td>
</tr>
<tr>
<th>Availability</th>
<td>This product is not out of stock.</td>
</tr>
</table>
JSFIDDLE
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- ExtJS——在展开/折叠时调整面板高度
- 分析高度属性时出现意外值{{specs.height}}.index.html
- 单击页面上的链接后高度发生变化
- 不加载宽度和高度的角度pintura
- 查找元素高度,包括边距
- 如何自动调整标签的高度以适应内容
- Javascript高度问题
- 使用JavaScript根据窗口/视口的高度动态调整图像大小
- 如何计算每个元素's的高度,并将这些值用作函数中的变量
- 如果宽度是百分比,如何设置以px为单位的图像高度
- 通过jquery设置最小高度
- 文档就绪提供了错误的选择器高度
- 调整缩放窗口高度提升缩放
- ui网格:在自定义表头模板中触发排序
- 根据图像高度添加类
- 检测非移动页面上的移动设备屏幕宽度和高度
- 修复了使用Jquery的列(表头问题)
- 更改代码镜像中TextArea的高度和宽度
- 根据不同分区中的其他表头高度调整表头高度