Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to create a div with </p> <p>left as -width of your image </p> <p>top as -height of your image</p> <p>width as width * 2 + width of view port(300)</p> <p>height as height * 2 + height of view port(300)</p> <p>html</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" /&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;meta charset=utf-8 /&gt; &lt;title&gt;JS Bin&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="outer"&gt; &lt;div id="inner"&gt; &lt;div id="bounds"&gt; &lt;/div&gt; &lt;div id="myimage"&gt; &lt;div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>css </p> <pre><code>#outer { border: solid 1px red; padding: 50px 30px 50px 30px; float: left; } #inner { width: 300px; height: 300px; border: solid 1px black; overflow:hidden; position:relative; } #myimage { background-image:url('http://upload.wikimedia.org/wikipedia/commons/9/9a/Sample_Floorplan.jpg'); background-position : 0,0; background-repeat:no-repeat; width: 648px; height: 438px; position:relative; } </code></pre> <p>javascript</p> <pre><code>var imgwidth = "648"; var imgheight = "438"; $("#bounds").css({ position:"absolute", left: -imgwidth + 10, top:-imgheight + 10, width: imgwidth * 2 + 300 - 20, height:imgheight * 2 + 300 - 20, } ); $("#myimage").draggable({ containment: "#bounds" }); </code></pre> <p>Checkout this bin </p> <p><a href="http://jsbin.com/atavub/14/" rel="nofollow">http://jsbin.com/atavub/14/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload