This has been driving me nuts. Every solution I find doesn’t work. Can someone please – once and for all instruct me on how to fix this issue:
Two flex boxes side by side inside a flex display.
Flex box 1 contains long text which needs to be shorted with ellipses. Instead, the long text causes a resize of the flex box 1. I do not want either flex box to resize or reposition based on the contents.
.wrapper {
width: 50%;
display: flex;
background-color: green;
}
.container {
flex: 1;
margin: 10px;
border: 2px solid blue;
height: 200px;
background: pink;
}
span {
user-select: none;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<div class="wrapper">
<div class="container">
<span>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</span>
</div>
<div class="container"></div>
</div>
2
Answers
If you are wanting the 2 boxes to stay equal width, I would just add a width to them (you’ll also need to give your span a width to make the ellipsis work):
First, get rid of the
<span>
and put that information into the first<div>
with the class = "container" and get rid of the second<div>
container class, but keep the first one. In CSS, remove .span, and in .container, add overflow: scroll;