I'm building a one line input control that mixes user edited text and non-editable blocks. I want to make easy for user to click on the first or last editable item and have the browser put focus into the element. For that, I need to set min-width:5px
for the first item and width:100%
for the last item like this:
<div class="app">
<div class="el1" contenteditable="true">should not collapse</div>
<div class="el2">block</div>
<div class="el3" contenteditable="true">should take 100% width</div>
</div>
.app { display: flex; }
.el1 { min-width: 5px; }
.el3 { width: 100%; }
.el2 { background-color: aquamarine; padding: 5px; }
However, the first time collapses on white-space. I've tried both flex-wrap: nowrap;
on .app
and white-space: nowrap;
on .el1
, but it doesn't give me the desired result.
Updates
It seems to be enough to set flex-shrink:0
for the .el1
as by default it's set to flex-shrink:1
and so as I understand it allows collapsing. But I'm not sure that's the way to go. Anyone can confirm?