JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<div id="container">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
Cool dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
<li role="presentation" class="divider"></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
</ul>
</div>
</div>
CSS
#container{
width:100%;
height:193vh;
}
.dropdown{
position:absolute;
bottom: 0;
}
.reverse {
top:auto;
bottom:100%;
}
JavaScript
$(".dropdown-toggle").click(function(){
// get the scollTop (distance scrolled from top)
var scrollTop = $(window).scrollTop();
// get the top offset of the dropdown (distance from top of the page)
var topOffset = $(".dropdown").offset().top;
// calculate the dropdown offset relative to window position
var relativeOffset = topOffset-scrollTop;
// get the window height
var windowHeight = $(window).height();
// if the relative offset is greater than half the window height,
// reverse the dropdown.
if(relativeOffset > windowHeight/2){
$(".dropdown-menu").addClass("reverse");
}
else{
$(".dropdown-menu").removeClass("reverse");
}
});