1

I want to create an application layout that has a top toolbar with a could of divs in it,

then a sidebar and a content window with a top nav

Desired Layout

I have got the structure almost working but I cannot scroll to the bottom of the content container. I want everything else to be fixed. I have included the code and a fiddle. I have a feeling it is to do with the h-screen I have put on the content container, but if I tried h-full it does not scroll at all.

<div class="h-screen  overflow-hidden" >
    <div class="p-4 bg-yellow-500">
        <div class="h-10 bg-green-500">

        </div>
        <div class="h-10 bg-blue-500">

        </div>
    </div>

    <div class="flex">
        <div class="w-48">
            sidebar
        </div>

        <div class="w-full bg-indigo-500 p-2 ">

            <div class="h-10 bg-orange-500 w-full">
                topnav
            </div>
            <div class=" flex-1 relative z-0 overflow-y-auto   bg-green-500 h-screen">
                content
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3"></div>
                <div class="h-10 bg-white m-3">Last One</div>

            </div>

        </div>
    </div>

</div>

https://jsfiddle.net/sg7aqxv9/5/

JaChNo
  • 1,493
  • 9
  • 28
  • 56

1 Answers1

2

You're running up against the flexbox minimum sizing algorithm, which is causing your layout to overflow. For a detailed explanation, see this post:

You're also being impeded by the overflow function, which requires a fixed length, so that can actually overflow something. See this post:

Taking those factors into consideration, you just need to add this to your code:

.main-container {
   display: flex;
   flex-direction: column;
   /* overflow: hidden is not necessary */
}

.secondary-container {
   overflow: auto;
}

.tertiary-container {
   display: flex;
   flex-direction: column;
}

revised demo

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