Update:
Thus, based on the question, we can simply use the CSS below to start scaling left or right, depending on the position of the elements in the parent container.
CSS change required in parent container as below
#mainDiv { display: inline-block; width: 82%; min-height: 100%; box-sizing: border-box; float: left; position:relative; margin: 0; padding: 3px; }
Please check out JSFiddle for a solution!
JSFiddle Demo
Old answer:
I assume that scaling in the center is a problem, since we zoom in from the middle, the table always exceeds the border of the container. I would suggest adding a CSS class below so that the endpoints are preserved.
.elementTable{ transform-origin: 0% 0%; }
Below is a working JSFiddle with implementation.
JSFiddle Demo
My assumption may be wrong, please explain that it is missing, and I will try to solve it!
source share