2

I have a layout where I need to hold <aside> with fixed width and middle content as fluid. Everything is fine but if you used <pre> element inside middle content and you will try to resize window to small resolution after that is <pre> without horizontal scroll and flex element is overflowed. <pre> element is as block element, with overflow: auto.

Any ideas how to resolve it?

Thanks a lot, best regards,

jsFiddle

body {
  margin: 0;
}

header {
  background-color: green;
}

footer {
  background-color: red;
}

header,
footer {
  width: 100%;
  height: 100px;
}

main {
  display: flex;
  background-color: purple;
}

aside {
  overflow-x: hidden;
  flex: 0 0 270px;
}

article {
  flex-grow: 1;
  min-height: 100vh;
  background-color: lightgray;
}

pre {
  overflow: auto;
  font-size: 87.5%;
  color: #dc3545;
}
<header>
  header
</header>
<main>
  <aside>
    aside left
  </aside>
  <article>
    <h1>CONTENT</h1>
    <pre>
&lt;button class=&quot;btn btn-primary num-badge num-badge--text-primary&quot; data-num-badge=&quot;9&quot;&gt;Primary button&lt;/button&gt;
&lt;button class=&quot;btn btn-primary num-badge num-badge--text-primary num-badge--border-primary&quot; data-num-badge=&quot;9&quot;&gt;Primary button&lt;/button&gt;
&lt;button class=&quot;btn btn-primary num-badge num-badge--text-primary num-badge--border-primary num-badge--font-awesome&quot; data-num-badge=&quot;&amp;#xf021;&quot;&gt;Primary button&lt;/button&gt;
&lt;a class=&quot;num-badge&quot; data-num-badge=&quot;9&quot;&gt;Basic Link&lt;/a&gt;;</pre>
  </article>
  <aside>
    aside right
  </aside>
</main>
<footer>
  footer
</footer>
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701

1 Answers1

3

You have the overflow: auto on the pre element.

pre {
  overflow: auto;
  font-size: 87.5%;
  color: #dc3545;
}

It cannot overflow itself. It overflows the parent.

So, move the overflow to article.

article {
  overflow: auto; /* new */
  flex-grow: 1;
  min-height: 100vh;
  background-color: lightgray;
}

revised jsfiddle

The problem and solution is explained in more detail here:

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701