I'm playing around with jquery UI and I noticed a weird bug. When i click a button which makes a div resizable, the div moves to a position below that button.
resizable.html:
<html>
<head>
<link href="my.css" rel="stylesheet" type="text/css"/>
<link href="jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script>
function makeResizable() {
$("#divRes").resizable();
}
</script>
<style>
</style>
</head>
<body>
<br><br><br><br><br><br><br><br><br><br>
<button onclick="makeResizable();">Make Resizable</button>
<div id="divRes" class="MyDiv"></div>
</body>
</html>
my.css:
.MyDiv {
position: absolute;
left: 50px;
top: 50px;
height: 100px;
width: 100px;
padding: 0px;
margin: 0px;
z-index: 1;
background-color: cyan;
}
So as soon as i click the make resizable button, the div becomes resizable but it also moves vertically below the button.
The weird part is this: IF i remove the css from my.css and place it inline between the
<style>
.MyDiv {
position: absolute;
left: 50px;
top: 50px;
height: 100px;
width: 100px;
padding: 0px;
margin: 0px;
z-index: 1;
background-color: cyan;
}
</style>
OR if i change the declaration of the div from:
<div id="divRes" class="MyDiv"></div>
to
<div id="divRes"></div>
and my.css to
#divRes {
position: absolute;
left: 50px;
top: 50px;
height: 100px;
width: 100px;
padding: 0px;
margin: 0px;
z-index: 1;
background-color: cyan;
}
THE ISSUE DOES NOT OCCUR.
But of course doing that is both undesirable and stupid. The issue cannot be reproduced in jsfiddle because obviously all css is inline. I can upload the files online in both versions if its necessary.
jquery versions:
jQuery UI - v1.8.20 - 2012-04-30
jQuery v1.7.2 jquery.com | jquery.org/license
Thanks in advance for any input.
EDIT: just tested it with jquery-ui 1.30.3 and jquery 1.9.1 ( latest ). the issue persists, so it's not due to an old version of it.
EDIT2: I've uploaded the files here http://speedy.sh/eBPea/resizable.zip
resizable.htm: demonstrates the problem
resizable2.htm: the problem does not appear if I don't use CSS classes ( not an option )
resizable3.htm: the problem does not appear if I include CSS classes in the html file ( not an option )