CSS horizontal scroll
You can use display:inline-block
with white-space:nowrap
. Write like this:
.scrolls {
overflow-x: scroll;
overflow-y: hidden;
height: 80px;
white-space:nowrap;
}
.imageDiv img {
box-shadow: 1px 1px 10px #999;
margin: 2px;
max-height: 50px;
cursor: pointer;
display:inline-block;
*display:inline;/* For IE7*/
*zoom:1;/* For IE7*/
vertical-align:top;
}
Check this http://jsfiddle.net/YbrX3/
Here's a solution with flexbox for images with variable width and height:
.container {
display: flex;
flex-wrap: no-wrap;
overflow-x: auto;
margin: 20px;
}
img {
flex: 0 0 auto;
width: auto;
height: 100px;
max-width: 100%;
margin-right: 10px;
}
<div class="container">
<img src="https://via.placeholder.com/100x100" />
<img src="https://via.placeholder.com/50x50" />
<img src="https://via.placeholder.com/5x50" />
<img src="https://via.placeholder.com/100x50" />
<img src="https://via.placeholder.com/50x100" />
<img src="https://via.placeholder.com/20x50" />
<img src="https://via.placeholder.com/50x30" />
<img src="https://via.placeholder.com/50x150" />
<img src="https://via.placeholder.com/250x50" />
<img src="https://via.placeholder.com/150x350" />
<img src="https://via.placeholder.com/50x350" />
<img src="https://via.placeholder.com/100x100" />
<img src="https://via.placeholder.com/50x50" />
<img src="https://via.placeholder.com/5x50" />
<img src="https://via.placeholder.com/100x50" />
<img src="https://via.placeholder.com/50x100" />
<img src="https://via.placeholder.com/20x50" />
<img src="https://via.placeholder.com/50x30" />
<img src="https://via.placeholder.com/50x150" />
<img src="https://via.placeholder.com/250x50" />
<img src="https://via.placeholder.com/150x350" />
<img src="https://via.placeholder.com/50x350" />
</div>