Scroll the block left to the desired location

Let’s start something easy. Check out my script to scroll the block left to the desired location.

block scroll left

.wrp {
display: block;
position: relative;
overflow: hidden;
visibility: visible;
overflow-x: scroll;
width: 100%;
height: 100px;
background: #ddeeff;
.blk {
display: block;
position: relative;
width: 1000px;
height: 500px;
z-index: 2;
margin-left: 100%;
background: #bbccdd;
.animate {
margin-left: 0%;
transition-property: margin-left;
transition-duration: 9s;
.knop {
display: block;
position: absolute;
width: 20px;
height: 20px;
right: 10px;
top: 50%;
background: green;
cursor: pointer;
<div class="wrp">
<div class="knop"></div>
<div class="blk"></div>
document.querySelector('.knop').onclick = function() {

Feel free to use it. You can adjust the script for your needs. Also hope it helps with your javascript problem which brought you here 😉

Leave a Reply

Your email address will not be published. Required fields are marked *