Here's my code
var move = document.getElementById('main').children;
var movel = 3;
var x = 0;
console.log(move.length);
function right(){
for (var i = 0; i <= move.length; i++) {
var cssPr = window.getComputedStyle(move[i], null).getPropertyValue("left");
var ppt = cssPr.replace("px", "");
var calc = parseFloat(ppt);
var calcFor = calc + movel;
move[i].style.left = calcFor+"%";
}
}
function left(){
for (var i = 0; i <= move.length; i++) {
var cssPr = window.getComputedStyle(move[i], null).getPropertyValue("left");
var ppt = cssPr.replace("px", "");
var calc = parseFloat(ppt);
var calcFor = calc - movel;
move[i].style.left = calcFor+"%";
}
}
.main {margin-left: 0%; width: 100%; max-height: 100px; position: relative; padding: 2%;}
.main div{width: 100px; height: 100px; display: inline-block; position: absolute;}
.p3{background-color: red; left: 50%; transition: all .4s; }
.p2{background-color: blue; left: 25%; transition: all .4s;}
.p1{background-color: black; left: 0%;transition: all .4s;}
button{ margin-top: 140px;}
<div class="main" id="main">
<div class="p1"></div>
<div class="p2"></div>
<div class="p3"></div>
</div>
<button onclick="right()">Move -></button>
<button onclick="left()""><-Move</button>