I need to create two divs: one (on the right) small, with short texts that don't wrap, and the other (on the left) bigger, occupying the remaining space of the screen, and wrapping the text where needed. I'm trying the following:
html,body {
margin: 0;
height: 100%;
}
body {
display: flex;
align-items: stretch;
}
#divL {
background-color: green;
flex: 1 0 auto;
padding: 1em;
}
#divR {
background-color: red;
white-space: nowrap;
padding-left: 1em;
padding-right: 1.5em;
overflow-y: auto;
}
<div id='divL'>
a short text
</div>
<div id='divR'>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
</div>
So far, so good. But the left panel will increase together with the text, pushing the right panel out of screen when the text is too large:
html,body {
margin: 0;
height: 100%;
}
body {
display: flex;
align-items: stretch;
}
#divL {
background-color: green;
flex: 1 0 auto;
padding: 1em;
}
#divR {
background-color: red;
white-space: nowrap;
padding-left: 1em;
padding-right: 1.5em;
overflow-y: auto;
}
<div id='divL'>
very long text very long text very long text very long text very long text very long text very long text very long text very long text very long text very long text very long text
</div>
<div id='divR'>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
<p>list of items</p>
</div>
I don't want to specify fixed widths, because the right panel has variable width (never too big, only two or three words in each line). How can I achieve such a simple design? Is it possible without specifying fixed widths somewhere?