【发布时间】:2014-09-05 17:02:33
【问题描述】:
我有一个表溢出其包含的 div。我想显示表格中的所有内容,所以表格必须超过 100% 的宽度才能这样做。问题是包含 div 不反映其子项的大小。我在这里有一个例子,它是一个响应式页面,但问题只发生在低宽度 - 在高宽度时很好。
<html>
<head>
<title>Test</title>
<style type="text/css">
body, table, td {
color : #1D1F22;
}
#content {
padding: 10px;
/*overflow: hidden; */
background-color:red;
}
.border {
background-color: #4385DB;
color : #4385DB;
}
table
{
word-break: break-all
}
@media(min-width: 800px) {
#content {
width : 98%;
}
}
</style>
</head>
<body>
<div id="content">
<table cellpadding="7" cellspacing="1" class="border">
<tr>
<td>VeryLongBitOfTextVeryLongBitOfText</td>
<td>VeryLongBitOfTextVeryLongBitOfText</td>
<td><img src="dogs.jpg" width="400" height="100" alt="trev"></td>
<td>VeryLongBitOfTextVeryLongBitOfText</td>
</tr>
</table>
</div>
</body>
</html>
【问题讨论】:
-
为什么不考虑在内容中使用滚动
overflow: scroll;?? -
你为什么不尝试将图像设置为宽度百分比和高度自动与最小宽度?