JSFiddle - React, Tailwind, and code Playground
by mkurzweil
HTML
<div class="page-wrapper">
<a class="popup-link" href="#">Click me to invoke a popup</a>
<div class="popup">
popup content
</div>
</div>
CSS
.page-wrapper{
width: 100%;
height: 500px;
background: rgba(22,22,22, 0.4);
position: relative;
}
.popup-link{
position: absolute;
top: 40%;
color: #fff;
display: block;
width: 100%;
text-align: center;
}
.popup{
width: 200px;
height: 200px;
background: #fff;
border-radius: 3px;
position: absolute;
top: 0%;
left: 50%;
margin-top: 0;
margin-left: -100px;
z-index: 20;
padding: 10px;
display: none;
opacity: 0;
top: 100%;
}
.popup-visible{
top: 50%;
margin-top: -100px;
opacity: 1;
}
JavaScript
$('.popup-link').on('click', function(){
/* if we don't use the timeout it has no transition */
$('.popup').show().animate({
top: "50%",
marginTop: "-100px",
opacity: 1
},2000);
});