JSFiddle - React, Tailwind, and code Playground
HTML
<div class="modal fade" id="modalPostBox1" tabindex="-1" role="dialog" aria-labelledby="modalPostBoxLabel" aria-hidden="true" style="border:1px solid black;">
<div class="modal-dialog" style="max-width:400px; margin: 0 auto;">
<div class="modal-content" style="min-height: 600px; height: auto;">
<div class="modal-body" id="this-is-body" style="height: 430px;padding:0px; overflow: auto;">
<div style="width:100%; " id="sticker">
<img class="replyOpener" style="width:100%; " id="image_E1C9BD2F-608A-8B71-CD90-D058B3B03816" src="http://www.rtacpa.com/wp-content/themes/thesis_18/custom/rotator/sample-1.jpg" alt="">
</div>
<ol class="ordered-comments" id="modalPostCommentList" style="margin: 30px 10px 10px 10px;">
<li>
<div class="comment-1 ordered-list-items" data-id="1322B587-1DB9-C87B-A6FD-90111533319B">
<div class="comment-1-right">
<div class="comment-name"
data-commentcontent="1322B587-1DB9-C87B-A6FD-90111533319B">I didn't think it
was that bad
</div>
</div>
</div>
</li>
<li>
<div class="comment-1 ordered-list-items" data-id="E6F8ED84-4FE3-2BF7-B2C9-F90726BCC601">
<div class="comment-1-right">
<div class="comment-name"
data-commentcontent="E6F8ED84-4FE3-2BF7-B2C9-F90726BCC601">So bad that you ate
it all
</div>
</div>
</div>
...
CSS
.stick {
position:fixed;
top:0;
}
li
{
padding:5px;
}
JavaScript
$(document).ready(function() {
var s = $("#sticker");
var pos = s.position();
$('#this-is-body').scroll(function() {
var windowpos = $('#this-is-body').scrollTop();
//console.log("Distance from top:" + pos.top + "<br />Scroll position: " + windowpos);
if (windowpos >= 154) {
s.addClass('stick');
} else{
s.removeClass('stick');
}
});
});