我有一个日志条目表,我想用两列显示:时间戳和日志条目本身。表格具有固定宽度。我希望时间戳列拉伸以适合时间戳本身的文本并且不再进一步,然后让表格的其余宽度被消息占用。我希望时间戳文本始终为一行,并让日志消息环绕。我有那部分工作,但对于我的生活,我无法弄清楚如何使列宽适合时间戳的文本宽度。我可以做一个固定的像素宽度,但这似乎很可疑。
编辑:更新代码示例:(http://jsfiddle.net/GH7jj/7/)
<div class="MainDiv">
<table class="LogTableStyle">
<tr>
<th>Time</th>
<th>Message</th>
</tr>
<tr>
<td class="LogTime">11/07/2012 07:38:14</td>
<td class="LogMessage">There was something that happened at this point. This is a pretty long message though. It should be wrapping around. I want the timestamp to be on that one line while giving this message as much room as possible. That'd be cool.</td>
</tr>
</table>
</div>
和CSS:
.MainDiv {
min-width:300px;
max-width:500px;
height:100%;
background-color:#F0F0FF;
margin:auto;
}
.LogTableStyle {
width:97%;
margin:auto;
border-collapse:collapse;
table-layout:fixed;
}
.LogTableStyle th {
font-family:Verdana, Geneva, sans-serif;
font-size:14px;
background-color:#333;
color:#FFF;
border:solid 1px #000;
padding:3px;
border-left-style: none;
border-right-style: none;
}
.LogTableStyle td {
font-family:Verdana, Geneva, sans-serif;
font-size:11px;
}
.LogTime {
white-space:nowrap;
}
.LogMessage {
overflow:hidden;
text-overflow:ellipsis;
}