I have a two column page, implemented via flex
. The right column is set up to have a small max-width
and the left column must take the rest of the page width.
I'm trying to add a pre
element into the main column with a nested code
inside, but the problem is that I can't make it scroll if the text in it is too wide.
Here's the fiddle to show what I'm doing.
Here's CSS:
.main{
display: flex;
}
.content{
flex: 4;
background-color: yellow;
}
.sidebar{
flex: 1;
background-color: lightgreen;
max-width: 100px;
min-width: 50px;
}
pre{
border-radius: 0.3em;
margin: 1.5em 0;
background-color: lightblue;
overflow-x: auto;
resize: vertical;
}
pre code{
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: break-word;
tab-size: 4;
cursor: text;
font-size: 12px;
font-family: 'Courier New', Courier, monospace;
line-height: 1.4;
}
Here's HTML:
<div class="main">
<div class="content">
<p>
Main content goes here.
</p>
<pre>
<code>
hFile = CreateFileW(fn[2], FILE_WRITE_DATA, 0, 0, CREATE_NEW, FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH, 0);
if(hFile == NULL)
{
//Do something
}
</code>
</pre>
</div>
<div class="sidebar">
Side Bar
</div>
</div>
My goal is to make that pre
box shrink horizontally along with the page and provide a horizontal scrollbar it in for the content that doesn't fit into it.
So what am I doing wrong?