【发布时间】:2014-01-29 08:17:43
【问题描述】:
我在 HTML 控件中水平显示图像。图像表位于主 DIV 内。 DIV 的 CSS 如下:
#main
{
width: auto;
height: auto;
margin: auto;
padding: 2px 0px 0px 0px;
border: 3px solid #ccc;
}
问题是主 DIV 边框没有延伸,图像从它上面掉出来,如下图所示:
这是 HTML 代码:
<body>
<div id="main">
...
<table>
<tr id="image-list">
</tr>
</table>
...
</body>
请建议如何更改代码,以便 DIV 边框根据其中的图像自动增加其宽度?
【问题讨论】:
-
您不应该将表格元素用于图像列表。考虑制作 ul/li 而不是 table/tr。如果您需要表格显示,请使用 display: table-cell。
标签: html css image html-table