JSFiddle - React, Tailwind, and code Playground
by evan
HTML
<div class="a">
<div class="config">
Configuration menu
</div>
<div class="b">
<div class="c">
In publishing and graphic design, lorem ipsum is a placeholder text commonly used to demonstrate the graphic elements of a document or visual presentation.
</div>
</div>
</div>
CSS
.a {
width: 208px;
height: 208px;
border: 1px solid #D5DBE1;
border-top: 0;
border-radius: 2px;
position: absolute;
top: 15px;
left: 15px;
background: #4C98FC;
overflow: hidden;
}
.b {
background: white;
position: absolute;
top: 2px;
transition: top .3s;
}
.config {
position: absolute;
top: 2px;
width: 100%;
text-align: center;
}
.c {
padding: 22px;
font-family: Futura;
font-size: 10pt;
}
JavaScript
$(function () {
$('.a .b').height(function () {
return $(this).parent().height() - 2;
});
var b = $('.b'),
a = $('.a');
var timeout = null;
a.on('mousemove', function (e) {
var bgOffsetY = e.pageY - a.offset().top;
if (bgOffsetY < 60) {
clearTimeout(timeout);
timeout = setTimeout(function () {
if (parseInt(b.css('top')) < 30) {
b.css({top: 30});
}
}, 600);
} else {
b.css({top: 2});
clearTimeout(timeout);
}
});
a.on('mouseleave', function () {
clearTimeout(timeout);
b.css({top: 2});
});
});