JSFiddle - React, Tailwind, and code Playground
by vol7ron
HTML
<html>
<head>
<link type="text/css" href="http://jqueryui.com/themes/base/jquery.ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/jquery-1.4.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="http://jqueryui.com/ui/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="http://jqueryui.com/ui/jquery.ui.resizable.js"></script>
<link type="text/css" href="http://jqueryui.com/demos/demos.css" rel="stylesheet" />
</head>
<body>
<div class="demo">
<div id="container" class="ui-widget-content">
<h3 class="ui-widget-header">Containment</h3>
<div id="resizable" class="ui-state-active">
<h3 class="ui-widget-header">Resizable</h3>
</div>
</div>
</div><!-- End demo -->
<div class="demo-description">
<p>Define the boundaries of the resizable area. Use the <code>containment</code> option to specify a parent DOM element or a jQuery selector, like 'document.'</p>
</div><!-- End demo-description -->
</body>
</html>
CSS
#container { width: 300px; height: 300px; }
#container h3 { text-align: center; margin: 0; margin-bottom: 10px; }
#resizable { background-position: top left; width: 150px; height: 150px; }
#resizable, #container { padding: 0.5em; }
JavaScript
$(function() {
var cn = $('#container');
var ch = cn.find('h3.ui-widget-header');
var rs = cn.find('#resizable');
var rh = rs.find('h3.ui-widget-header');
rs.resizable({
//containment: '#container'
maxWidth: cn.width()
- parseInt(cn.css('padding-left'))
- parseInt(cn.css('padding-right'))
- parseInt(cn.css('border-left-width'))
- parseInt(cn.css('border-right-width'))
, maxHeight: cn.innerHeight()
- parseInt(cn.css('padding-top'))
- parseInt(cn.css('padding-bottom'))
- parseInt(cn.css('border-top-width'))
- parseInt(cn.css('border-bottom-width'))
- ch.outerHeight(true)
- parseInt(ch.css('padding-top'))
- parseInt(ch.css('padding-bottom'))
- parseInt(rs.css('padding-top'))
- parseInt(rs.css('padding-bottom'))
, minHeight: rh.outerHeight(true)
+ parseInt(rh.css('padding-top'))
+ parseInt(rh.css('padding-bottom'))
, minWidth: rs.width()
});
});