I have a container with a list inside. List items can be dragged by moving with the mouse.
The container scrolls with:
overflow-y: scroll;
By setting this property, Chrome automatically sets the overflow-x property to 'auto'. If I set overflow-x: visible , it is ignored by Chrome. If I set overflow-x: hidden , then obviously the item is cropped.
When I drag a list item out of the left or top edge of the container, it is cropped around the edges of the container. If I pulled it from the right or bottom edge, the container scrolls to fit it. I would like the element to be able to be dragged out of the container without cropping it and without it to start scrolling.
Given that the container must be set to overflow-y: scroll , and this in turn forces Chrome to install overflow-x: auto , is there any way to achieve this or is it impossible?
Codepen: http://codepen.io/Pedr/pen/azLWeY
Note: I know that I can crack it with an add-on to compensate for the container (so that the container’s limits actually end outside its visual borders), but this is not an option in my situation.
$(function() { $('.Wrapper').mousemove(function(event){ $('.Item').offset({left: event.pageX, top: event.pageY}); }); })
html, body { height: 100%; } .Wrapper { width: 100%; height: 100%; position: absolute; } .Container { background: grey; position: absolute; width: 50%; left: 25%; min-height: 100%; overflow-y: scroll; overflow-x: hidden; // Clips Item // If left at auto it will clip the item on the top and left edge and scroll if the item overlaps the bottom or right edge. } .Item { padding: 20px; background: red; position: absolute; width: 600px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="Wrapper"> <div class="Container"> <div class="Item">ITEM</div> </div> </div>
html css overflow drag-and-drop clip
Undistraction
source share