I am trying to build a small admin dashboard for a personal application but i can not figure out how to make sure the page itself can now overflow, but rather the elements inside do.
this is the example code i am trying to get to work:
<body>
<div class="h-screen w-screen bg-teal-100 flex overflow-hidden">
<!-- Toolbar with a fixed width -->
<div class="h-full bg-blue-50" style="width: 100px;">Toolbar</div>
<!-- Container for Sidebar and Content 1, taking up the remaining width -->
<div class="flex-grow h-full bg-orange-50 flex">
<!-- Sidebar with a fixed width -->
<div class="bg-purple-50" style="width: 200px;">Sidebar</div>
<!-- Content 1 taking the remaining space -->
<div class="flex-grow h-full bg-indigo-500 flex flex-col">
<div class="bg-green-50">A</div>
<div class="bg-purple-50">B</div>
<div class="flex-grow bg-teal-200 flex flex-col">
<div class="bg-green-50">Header</div>
<!-- Table div with growing and scrolling capability -->
<div class="flex-grow bg-red-200 overflow-auto">
<!-- Oversized content to demonstrate scrolling -->
<div class="w-[200vw] h-[200vh] text-white">
H (large content here to activate scrolling)
</div>
</div>
<div class="bg-purple-50">Footer</div>
</div>
</div>
</div>
</div>
</body>
what i am trying to achive is to have a table:
<div class="w-[200vw] h-[200vh] text-white">
H (large content here to activate scrolling)
</div>
where if the table overflows i get scrollbars only for that table. This is driving me insane
2
Answers
Explanation:
h-screen w-screen
on the main container ensures that the container takes the full height and width of the viewport.overflow-hidden
on the main container prevents the page itself from scrolling.flex-grow
classes ensure that the remaining space is used by the content area, withflex
ensuring the layout remains flexible.overflow-auto
on the div containing the oversized table content (w-[200vw] h-[200vh]
) ensures that only this div will scroll when the content overflows.In such a realization the scrollable div must have an explicit height specified.
This line
should be for example
codepen