bgraf,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
* { box-sizing: border-box;margin: 0;padding: 0; }
.slider {
width: 300px;
height: 170px;
overflow: hidden;
position: relative;
}
.slider__arrow {
width: 20px;
height: 20px;
position: absolute;
top: 50%;
background-color: #3294FD;
text-align: center;
line-height: 20px;
color: #fff;
z-index: 9;
cursor: pointer;
}
.slider__left { left: 0; }
.slider__right { right: 0; }
.slider__container {
width: 900px;
height: 170px;
position: absolute;
top: 0;
left: 0;
}
.slider__item {
width: 100px;
height: 170px;
line-height: 170px;
background: pink;
display: block;
float: left;
text-align: center;
}
.slider__item:hover {
background-color: #F7F7F7;
}
.slider__arrow.hide{
display: none;
}
.slider {
margin: 20px auto;
}
.slider__container.animate{
transition: left 1.2s cubic-bezier(.455, .03, .515, .955);
}
.slider__container.left{
left: -100px;
}
</style>
<script>
window.addEventListener("DOMContentLoaded", function() {
[].forEach.call( document.querySelectorAll('.slider'), function(slider) {
var left = slider.querySelector(".slider__left"),
right = slider.querySelector(".slider__right"),
container = slider.querySelector(".slider__container");
right.addEventListener("click", function() {
var last = container.querySelector(".slider__item:last-child");
var first = container.querySelector(".slider__item:first-child");
container.classList.remove("animate");
if (!container.classList.contains("left")) {
container.classList.add("left");
container.insertBefore(last, first);
}
document.documentElement.clientWidth;
container.classList.add("animate");
container.classList.remove("left")
});
left.addEventListener("click", function() {
var first = container.querySelector(".slider__item:first-child");
container.classList.remove("animate");
if (container.classList.contains("left")) {
container.classList.remove("left");
container.appendChild(first)
}
document.documentElement.clientWidth;
container.classList.add("animate");
container.classList.add("left")
})
});
});
</script>
</head>
<body>
<div class="slider">
<div class="slider__arrow slider__left"><</div>
<div class="slider__arrow slider__right">></div>
<div class="slider__container">
<div class="slider__item">1</div>
<div class="slider__item">2</div>
<div class="slider__item">3</div>
<div class="slider__item">4</div>
<div class="slider__item">5</div>
<div class="slider__item">6</div>
<div class="slider__item">7</div>
<div class="slider__item">8</div>
<div class="slider__item">9</div>
</div>
</div>
<div class="slider">
<div class="slider__arrow slider__left"><</div>
<div class="slider__arrow slider__right">></div>
<div class="slider__container">
<div class="slider__item">1</div>
<div class="slider__item">2</div>
<div class="slider__item">3</div>
<div class="slider__item">4</div>
<div class="slider__item">5</div>
<div class="slider__item">6</div>
<div class="slider__item">7</div>
<div class="slider__item">8</div>
<div class="slider__item">9</div>
</div>
</div>
<div class="slider">
<div class="slider__arrow slider__left"><</div>
<div class="slider__arrow slider__right">></div>
<div class="slider__container">
<div class="slider__item">1</div>
<div class="slider__item">2</div>
<div class="slider__item">3</div>
<div class="slider__item">4</div>
<div class="slider__item">5</div>
<div class="slider__item">6</div>
<div class="slider__item">7</div>
<div class="slider__item">8</div>
<div class="slider__item">9</div>
</div>
</div>
</body>
</html>