I need the child element to behave on hover as that the red border (of child element) should be on the same line as the blue one (parent element) from top, left, bottom and right side. Can I do that by padding? There are several boxes with the same structure but different width and height, and with the different length of text (some of them are on two or three lines).
If it is impossible to do it via padding, how can I achieve the same effect via another method?
The code is here
* {
box-sizing: border-box;
}
.out {
display: -webkit-box;
display: flex;
-webkit-box-pack: center;
justify-content: center;
width: 200px;
height: 200px;
margin: 2rem auto;
border: 1px solid blue;
}
.out .in {
font-size: 20px;
line-height: 1;
display: inline-block;
text-align: center;
border: 1px solid red;
padding: 20px;
margin: auto;
transition: padding .7s;
}
.out:hover .in {
padding-top: 90px;
padding-bottom: 90px;
padding-left: 40px;
padding-right: 40px;
background: rgba(0,0,0,.2);
}
<div class="out">
<p class="in">
Hello Friend
</p>
</div>
<div class="out">
<p class="in">
Hello Friend
</p>
</div>
<div class="out">
<p class="in">
Hello Friend this is a new text
</p>
</div>
<div class="out">
<p class="in">
Hello
</p>
</div>
Thanks