I am trying to create a simple carousel-like list of icons via Javascript and CSS. But it does not seem to work in my way. Can anyone help? This is my code
JS
var container = document.getElementById('container');
var foo = [];
for (var i = 0; i < 5; i++) {
foo[i] = document.createElement('div');
foo[i].id = 'SingleElement';
foo[i].innerHTML = '<img alt="" src="http://www.placehold.it/300x200"/>';
container.appendChild(foo[i]);
}
HTML
<div id="container"></div>
and CSS
#container {
overflow-x:scroll;
white-space: nowrap;
float:left;
}
#SingleElement {
float:left;
white-space: nowrap;
}
img {
display:inline-block;
}
and fiddle example. Thank you.