Child flex item is overflowing the width of the parent container. I tried setting min-width:0 as well but still it is not working.
Here is my HTML and CSS code :
.parent{
display: flex;
border: 2px solid red;
}
.child1{
background: cyan;
height: 40px;
width: 40px;
flex-shrink: 0;
}
.child2 {
background: pink;
height: 20px;
width: 20px;
}
.child3 {
background: yellow;
height: 20px;
min-width: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<div class='parent'>
<div class='child1'>1</div>
<div>
<div class='child2'>2</div>
<div class='child3'>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus sagittis odio, ac pulvinar tortor sagittis et. In hac habitasse platea dictumst. Phasellus ut velit dolor. Vestibulum pulvinar orci libero, in aliquet arcu auctor non. Morbi volutpat elit id lacus cursus, at imperdiet tellus eleifend. Morbi euismod vehicula urna, sed pretium felis ullamcorper vitae. Nunc at ligula a odio eleifend convallis eget sed orci. Praesent fermentum, sem in congue tempus, ex diam suscipit neque, in ullamcorper orci erat eu orci.</div>
</div>
</div>
My motive is to prevent the child3
from overflowing the parent container and show ellipsis(...) when it overflows.
Any help is appreciated.