Check out this jsFiddle I just made -> https://jsfiddle.net/larsjueljens/tLq2t04a/8/
The code consists of three div sections:
<div class="left">
This content is on the left
</div>
<div class="divider">
</div>
<div class="right">
This content is on the right
</div>
Initial styling:
.left {
position: fixed;
top: 0px;
left: 0px:
width: 200px;
bottom: 0px;
}
.divider {
position:fixed;
top: 0px;
left: 200px;
width: 20px;
bottom: 0px;
background-color: blue;
}
.right {
position: fixed;
top: 0px;
right: 0px;
left: 220px;
bottom: 0px;
}
Javascript snippet:
var isMouseDown = false,
leftContent = document.querySelector('.left'),
divider = document.querySelector('.divider'),
rightContent = document.querySelector('.right');
divider.addEventListener('mousedown', function (event) {
isMouseDown = true;
});
divider.addEventListener('mouseup', function (event) {
isMouseDown = false;
});
divider.addEventListener('mousemove', function (event) {
if (isMouseDown) {
leftContent.style.width = (event.clientX - 10) + 'px';
divider.style.left = (event.clientX - 10) + 'px';
rightContent.style.left = (event.clientX + 10) + 'px';
}
});