JSFiddle - React, Tailwind, and code Playground

by TJ VanToll

HTML

<link rel="stylesheet" href="http://code.jquery.com/ui/jquery-ui-git.css">
<script src="http://code.jquery.com/ui/jquery-ui-git.js"></script>
<div class="block blue" id="blueBlock"></div>
<div class="block red" id="redBlock">
    <div class="content">
        <button>Position</button> 
    </div>     
</div>

<div id="uiPosition"></div>

CSS

body {
    margin: 0;
    padding: 0;
}
body > div[style*='display'] {
    /* Workaround */
    /* position: absolute; */
}
.blue {
    background: blue;
    float: left;
    width: 100px;
}
.red {
    background: red;
    float: left;
    overflow-y: hidden;
}
.content {
    width: 2000px;
    height: 400px;
    border: 2px solid white;
}
#uiPosition {
    width: 100px;
    height: 100px;
    background: #ccc;
}

JavaScript

$( "#redBlock" ).css({
    width: $( window ).width() - $( "#blueBlock" ).width()
});
$( ".block" ).css({
    height: $( window ).height()
});

$( "button" ).on('click', function (e) {
    $( "#uiPosition" )
        .position({
            my: "left top",
            at: "left bottom",
            of: e.target,
            within: $( "#redBlock" ),
            collision: "flip"
        });
});