我有几个包含图像的 div 元素,每个图像的高度设置为 100%,计算宽度。高度工作正常,但父 div 具有图像的实际宽度,大于计算宽度。这会在图像之间产生间隙。如何使 div 在显示时具有图像的宽度(而不是文件本身的宽度)?只能用 html/CSS 解决吗?
HTML:
<table>
<tr>
<td align-"center" valign="middle" style="background:#000;">
<div class="scrollable">
<div class="items">
<div>
<img style="height:100%;" src="001.png">
</div>
</div>
</div>
</td>
</tr>
</table>
CSS:
table {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
border-collapse: collapse;
border: 0;
}
td {
width: 100%;
height: 100%;
padding: 0;
border: 0;
}
.scrollable {
position: relative;
overflow: hidden;
width: 100%;
height: 100%;
max-height: 1000px;
}
.scrollable .items {
width: 25000px;
height: 100%;
position: absolute;
}
.items {float: center;}
.items div {
float: left;
width: auto;
padding: 0;
margin: 0;
}
有任何想法吗?坦克!