I have two panels side by side. The right-hand one contains species names, which should not wrap (they're small enough to occupy only a small part of the screen). The left-hand panel contains more things, and occupy most of the screen. Here's my code.
html,body {
height: 100%;
}
body {
display: flex;
margin: 0;
overflow-y: hidden;
}
#left {
background-color: skyblue;
flex-grow: 1;
padding: 1em;
}
#right {
background-color: indianRed;
white-space: nowrap;
padding: 1em;
display: flex;
flex-direction: column;
}
<div id='left'>
Some text wide enough to compete with the red panel -- some more words needed.
</div>
<div id='right'>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
</div>
When there's no scrollbar, the width of the right-hand panel is correct. But as soon as I add a vertical scrollbar (overflow-y: auto
), it's width gets much smaller, creating also a horizontal scrollbar. Why? And how to solve it? I only want the vertical scrollbar. The width of the panel should be enough to contain all the words on it.
html,body {
height: 100%;
}
body {
display: flex;
margin: 0;
overflow-y: hidden;
}
#left {
background-color: skyblue;
flex-grow: 1;
padding: 1em;
}
#right {
background-color: indianRed;
white-space: nowrap;
padding: 1em;
display: flex;
flex-direction: column;
overflow-y: auto;
}
<div id='left'>
Some text wide enough to compete with the red panel -- some more words needed.
</div>
<div id='right'>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
<p>Some names.</p>
<p>Some names a little larger.</p>
</div>