At the top and bottom of the visible area of the jQueryUI dialog I have divs, represented by the gray boxes, the .nav
elements in the snippet, and I want them to remain in a fixed position when you scroll within the dialog. I set position: absolute
for the gray boxes, yet they still scroll with the rest of the content in the dialog. How can I keep them at a fixed position within the dialog?
$(document).ready(function() {
var opts = {
modal: true,
height:300,
};
$('#wrapper').dialog(opts);
$('#wrapper').dialog('open');
});
.images {
z-index: 1;
}
.image {
display: inline-block;
border: 1px solid black;
width: 100%;
height: 500px;
}
.nav {
width: 90%;
height: 30px;
z-index: 2;
background-color: rgba(192, 192, 192, 0.7);
position: absolute;
}
.top {
top: 0px;
}
.bottom {
bottom: 0px;
}
<link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<div id='wrapper'>
<div class='top nav'>
</div>
<div class='bottom nav'>
</div>
<div class='images'>
<div class='image'>
</div>
<div class='image'>
</div>
<div class='image'>
</div>
</div>
</div>