0
$(document).ready(function() {
    $( "#box" ).resizable();
});

.container {
    width: 450px;
    height: 450px;
    background-color: #000;
}

#box {
    width: 150px;
    height: 150px;
    background-color: red;
    padding: 0.5em; 
}

<div class="container">
    <div id="box">
    </div>
</div>

All I see is a red box, inside a black box, cannot see the resize icon at all like in the example here:

http://jqueryui.com/resizable/#helper

I looked at their css file, it seems like with the class .ui-widget-content it works, but why?

What makes that resize icon popup in there? Why doesn't it work?

there:

<html>
<head id="html">
<title>Jquery project</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

</head>

<div class="container">
    <div id="box">
    </div>
</div>
<style>
.container {
    width: 450px;
    height: 450px;
    background-color: #000;
}

#box {
    width: 150px;
    height: 150px;
    background-color: red;
    padding: 0.5em; 
}
</style>
<script>
$(document).ready(function() {
    $( "#box" ).resizable();
});
</script>
</html>
4

2 回答 2

1

You're missing the jQuery UI stylesheet:

<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet"/>

The entire jQuery UI project uses stylesheets to determine the look and feel of the widgets. The resizable icon is in the stylesheet:

.ui-icon-gripsmall-diagonal-se {
    background-position: -64px -224px;
}
.ui-icon, .ui-widget-content .ui-icon {
    background-image: url("images/ui-icons_222222_256x240.png");
}

The width and height of your element is controlled via styles. On the jquery download page, there is a section (at the bottom) to customize the look and feel. You're free to design your own; the one that I referenced is the default.

于 2013-08-22T19:22:50.257 回答
-1

就用这个....

#box { resize:both; }

在 CSS 中

于 2013-08-22T19:27:15.320 回答