我正在嘗試使用表格創建水平圖像滑動條。我想要顯示5張圖像,無論頁面寬度(它的大小是否正確),但是,滾動不起作用。嘗試使用表格獲得水平滾動
我懷疑我在表中使用了錯誤的css。
如果有更好的解決方法,我不需要使用表格。
這裏是小提琴:https://jsfiddle.net/vsadm9qz/
HTML
<div class="galleryWrap">
<table border="0">
<tbody>
<tr>
<td>
<div class="horizontalGalleryImageHolder">
<img id="1" src="http://placehold.it/300x300?text=IMG+1" style="max-height: 390px;" />
</div>
</td>
<td>
<div class="horizontalGalleryImageHolder">
<img id="2" src="http://placehold.it/300x300?text=IMG+2" style="max-height: 390px;" />
</div>
</td>
<td>
<div class="horizontalGalleryImageHolder">
<img id="3" src="http://placehold.it/300x300?text=IMG+3" style="max-height: 390px;" />
</div>
</td>
<td>
<div class="horizontalGalleryImageHolder">
<img id="4" src="http://placehold.it/300x300?text=IMG+4" style="max-height: 390px;" />
</div>
</td>
<td>
<div class="horizontalGalleryImageHolder">
<img id="5" src="http://placehold.it/300x300?text=IMG+5" style="max-height: 390px;" />
</div>
</td>
<td>
<div class="horizontalGalleryImageHolder">
<img id="6" src="http://placehold.it/300x300?text=IMG+6" style="max-height: 390px;" />
</div>
</td>
<td>
<div class="horizontalGalleryImageHolder">
<img id="7" src="http://placehold.it/300x300?text=IMG+7" style="max-height: 390px;" />
</div>
</td>
<td>
<div class="horizontalGalleryImageHolder">
<img id="8" src="http://placehold.it/300x300?text=IMG+8" style="max-height: 390px;" />
</div>
</td>
<td>
<div class="horizontalGalleryImageHolder">
<img id="9" src="http://placehold.it/300x300?text=IMG+9" style="max-height: 390px;" />
</div>
</td>
<td>
<div class="horizontalGalleryImageHolder">
<img id="10" src="http://placehold.it/300x300?text=IMG+10" style="max-height: 390px;" />
</div>
</td>
<td>
<div class="horizontalGalleryImageHolder">
<img id="11" src="http://placehold.it/300x300?text=IMG+11" style="max-height: 390px;" />
</div>
</td>
<td>
<div class="horizontalGalleryImageHolder">
<img id="12" src="http://placehold.it/300x300?text=IMG+12" style="max-height: 390px;" />
</div>
</td>
</tr>
</tbody>
</table>
</div>
CSS
body {
margin: 0;
}
table {
border-collapse: collapse;
}
td {
width: 20%;
padding: 0px;
}
img {
width: 100%
}
.galleryWrap {
width: 100%;
overflow-x: scroll;
}
表是不是真的適合這種。你可以使用其他的東西嗎? – Harangue
是的,我嘗試使用'inline-block',但是也失敗了,桌子只是我最接近的。但無論如何,只要我仍然只能顯示5張圖像,而且它們之間沒有空格,它可以做得很好。 –