When I use max-width
in order to stop text from occupying too much width, the text indeed moves to a new line but some unwanted white space is created.
The fiddle you will see is very similar to my code and shows what I'm trying to achieve.
My fiddle: https://jsfiddle.net/dpfryqsz/
.parent {
display: flex;
align-items: center;
height: 100px;
width: 500px;
margin: 20px 0;
background-color: green;
}
.children {
display: flex;
align-items: center;
height: 100%;
max-width: 160px;
background-color: red;
color: white;
font-size: 20px;
flex: none;
}
.parent::after {
content: "";
height: 2px;
width: 0;
background-color: black;
transition: width 0.5s ease;
}
.parent:hover::after {
width: 100%;
}
<div class="parent">
<div class="children">
Monkey eats
</div>
</div>
<div class="parent">
<div class="children">
Monkey eats tastyyy banana
</div>
</div>