Skip to content

Instantly share code, notes, and snippets.

@nladart
Created May 8, 2014 04:08
Show Gist options
  • Save nladart/9256e6d8eb095d177838 to your computer and use it in GitHub Desktop.
Save nladart/9256e6d8eb095d177838 to your computer and use it in GitHub Desktop.
horizontal scroll on small. Key parts of CSS are white space no wrap and overflow scroll touch
<div class="container">
<ul>
<li><img src="http://placehold.it/250x175"></li>
<li><img src="http://placehold.it/250x175"></li>
<li><img src="http://placehold.it/250x175"></li>
<li><img src="http://placehold.it/250x175"></li>
<li><img src="http://placehold.it/250x175"></li>
<li><img src="http://placehold.it/250x175"></li>
<li><img src="http://placehold.it/250x175"></li>
<li><img src="http://placehold.it/250x175"></li>
<li><img src="http://placehold.it/250x175"></li>
<li><img src="http://placehold.it/250x175"></li>
</ul>
</div>
/* Begin demo styles */
body {
font-family: 'Helvetica Neue', Arial, sans-serif;
}
a {
text-decoration: none;
}
/* End demo styles */
.container {
max-width: 1140px;
margin: 0 auto;
text-align: center;
}
.container ul {
list-style-type: none;
padding: 0;
overflow-x: scroll;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
}
@media screen and (min-width: 800px) {
.container ul {
white-space: normal;
}
}
.container ul li {
display: inline-block;
}
.container ul li a {
display: inline-block;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment