<div class="wrapper">
<div class="leftSidebar">
Left
</div>
<div class="rightSidebar">
Right
</div>
<div class="element">
</div>
</div>
html, body {
display: block;
width: 100%;
height:100%;
margin: 0;
padding: 0;
}
.wrapper {
display: block;
width: 100%;
height: 100%;
background-color: red;
overflow: hidden;
}
.leftSidebar, .rightSidebar {
display: inline-block;
float:left;
width: 50%;
height: 100%;
text-align: center;
}
.leftSidebar {
background-color: #C0C0C0;
}
.rightSidebar {
background-color: #E0E0E0;
}
.element {
display: block;
position: absolute;
top: 0;
left: 50%;
width: 30px;
border: 1px solid #000000;
height: 100%;
background-color: rgba(255, 255, 255, 0.75);
margin: 0 0 0 -16px;
}
.selectOff {
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
}
$(document).ready(function(){
$('html').on('mousedown','.element',function() {
$(this).css('cursor','e-resize').addClass('elementMove');
$('.leftSidebar, .rightSidebar').addClass('selectOff');
$('.wrapper').on('mousemove',function(e) {
console.log('run');
var CursorPosition = e.pageX - $('body').offset().left;
var WrapperWidth = $('.wrapper').width();
$('.elementMove').css('left',CursorPosition);
$('.leftSidebar').css('width',CursorPosition);
$('.rightSidebar').css('width',WrapperWidth - CursorPosition);
});
});
$('html').on('mouseup','.element',function() {
$(this).css('cursor','default').removeClass('elementMove');
$('.leftSidebar, .rightSidebar').removeClass('selectOff');
$('.wrapper').unbind('mousemove');
});
});