JSFiddle - React, Tailwind, and code Playground
HTML
<h1>ATM Stuff</h1>
<a class="openme">Find ATM Locations</a>
<div id="menu">
<div id='arrow'></div>
<a href="#">My Accounts</a>
<a href="#">Testing Options...</a>
<a href="#">More Options...</a>
</div>
<br />
CSS
a{
text-decoration: none;
color: inherit;
}
.openme {
display: inline-block;
color: #fff;
background-color: #333;
margin-top: 100px;
padding: 10px;
border: solid 1px #000;
border-radius: 3px;
cursor: pointer;
}
#menu{
opacity: 0;
visibility: hidden;
position: absolute;
padding:0px;
border: solid 1px #000;
border-radius: 3px;
background: -webkit-linear-gradient(top, #444 45%, #333 55%);
background: -moz-linear-gradient(top, #444 45%, #333 55%);
}
#menu.show {
opacity: 1;
visibility: visible;
}
#menu a{
float:left;
margin: 7px;
padding: 10px 20px;
font-weight: bold;
font-size: 20px;
text-align: center;
border-radius: 5px;
background-image: -webkit-gradient(linear, 0% 50%, 0% 51%, from(#fff), to(#edeff3));
background-image: -moz-linear-gradient(top, #fff, #edeff3);
}
#arrow {
position: absolute;
bottom: -40px;
/* Create the arrow using borders */
border-style: solid;
border-width: 20px;
border-color: transparent;
border-top-color: #333;
}
JavaScript
var $menu = $('#menu');
var $arrow = $('#arrow');
var $openme = $('.openme');
// Click "Open Me" button to show the menu
$openme.bind('click', function() {
// Position menu to where button is
$menu.css({
// Position menu above button
top: $openme[0].offsetTop - $menu.height() - parseFloat($arrow.css('border-top-width')),
left: $openme[0].offsetLeft
});
// Position arrow correctly
$arrow.css({
left: $openme[0].offsetLeft+$openme.width()-parseFloat($arrow.css('border-top-width'))*2
});
// Toggle menu's opacity
$menu.toggleClass('show');
})