I need to make a responsive web, so that the width of parent is dynamic. There are two flex items, one is long (dynamic) and another one is short (static).
I hope the result can look like the second line, that the long text is broken (or hidden when overlap), and the short text is always displayed correctly.
I tried to use flex-shrink: 0
but seems there is always an overflow.
How can I get rid of the overflow in this case?
I do need flex layout, and the js should not be involved.
.parent {
display: flex;
flex-direction: row;
width: 15rem;
background: yellowgreen;
padding: 10px;
overflow: hidden;
}
.flex-item {
width: 10em;
padding: 10px;
background: yellow;
flex: 1 1 50%;
}
.block1 {
background: red;
}
.block2 {
background: orange;
}
.nos {
flex-shrink: 0 !important;
}
<div class="parent">
<div class="flex-item">
<div class="block1">
longlonglonglonglonglonglonglonglonglonglonglonglonglong
</div>
</div>
<div class="flex-item nos">
<div class="block2">
Display
</div>
</div>
</div>
<br/>
<div class="parent">
<div class="flex-item">
<div class="block1">
longlonglonglonglong...
</div>
</div>
<div class="flex-item">
<div class="block2">
Display
</div>
</div>
</div>
`eak a line? – Penguin9 Jan 16 '17 at 13:15