JSFiddle - React, Tailwind, and code Playground
HTML
<div id=page>
<a id=ahover href="#">Hover me</a><br>
Here is the box that slides:
<div id=slidebox>
I am the content of the slide box (line1).<br>
I am the content of the slide box (line2).<br>
<a id=button href="#">I am some button in the slide box</a><br>
I am the content of the slide box (line3).<br>
I am the content of the slide box (line4).
<div id=someform>
Some box with a form or anything...<br>
<input type=text value="Text Box">
</div>
I am the content of the slide box (line5).<br>
I am the content of the slide box (line6).
</div>
And this is after the box.
</div>
CSS
#page {
font-size: calc( (35vw + 65vh) / 30); /* just some responsive design as a bonus */
}
#slidebox {
background-color: #e8e8e8;
visibility: hidden;
font-size: 0; /* animated from 0 to 100% */
opacity: 0; /* optional */
transition: 0.5s;
}
a#ahover:hover ~ #slidebox {
visibility: visible;
font-size: 100%; /* animated from 0 to 100% */
opacity: 1; /* optional */
}
a#ahover:not(:hover) ~ #slidebox * {
border-top: 0;
border-bottom: 0;
/* Put here anything vertical that uses px as unit, in this case the borders */
}
a#button {
display: inline-flex;
align-items: center;
justify-content: center;
position: relative;
width: 20em;
height: 3em;
padding: 0.5em;
border: 2px solid #0080ff;
border-radius: 0.4em;
background-color: #8fbfef;
color: #404040;
box-sizing: border-box;
}
#someform {
margin-top: 1em;
margin-bottom: 1em;
padding: 1em 4em 1em 4em;
background-color: #d8ffd8;
border: 1px solid #888888;
}
#someform input {
display: inline-block;
box-sizing: border-box;
font-size: 125%;
padding: 0.5em;
width: 50%; /* anything horizontal can still be in px or % */
border-radius: 0.4em;
border: 1px solid red;
}