Resizable and draggable box, scrolling problem in the container

Resizable and draggable box, scrolling problem in the container

  1. <!DOCTYPE html> 
  2. <html> 
  3. <head> 
  4. <meta charset="utf-8"> 
  5. <title>jQuery UI Draggable - Handles</title> 
  6. <link rel="stylesheet" href="http://jqueryui.com/themes/base/jquery.ui.all.css"> 
  7. <script src="http://jqueryui.com/jquery-1.4.4.js"></script> 
  8. <script src="http://jqueryui.com/ui/jquery.ui.core.js"></script> 
  9. <script src="http://jqueryui.com/ui/jquery.ui.widget.js"></script> 
  10. <script src="http://jqueryui.com/ui/jquery.ui.mouse.js"></script> 
  11. <script src="http://jqueryui.com/ui/jquery.ui.draggable.js"></script> 
  12.     <script src="http://jqueryui.com/ui/jquery.ui.resizable.js"></script> 

  13. <style> 

  14. #draggable2 { width: 200px; height: 200px; float: left; }
  15. #container {
  16. position: relative;
  17. float:left;
  18. border: 3px #000 solid;
  19. overflow:scroll;
  20. width: 50%;
  21. height: 350px;
  22. background-color:#FFFFFF;
  23. }
  24. </style> 
  25. <script> 
  26. $(function() {
  27. $( "#draggable2" ).draggable();
  28. $( "#draggable2" ).resizable();
  29. $( "div, p" ).disableSelection();
  30. });
  31. </script> 
  32. </head> 
  33. <body> 

  34. <div id="container">
  35.     <div style=" background-color:#FFF" id="draggable2" class="ui-widget-content"> 
  36.        Box
  37.     </div> 
  38. </div>


  39. </body> 
  40. </html>


This is my code, Change the box position.  When the scroll bar appear, resize the box and you'll see scroll bar disappeared.

How can i fix this ?

Thanks.