I am currently working on an angular app integrated with bootstrap 4. The challenge I am facing is related to the layout design. I have a fixed navbar at the top and a content area below it. Within the content area, I have a div that includes header and footer content while the main content section in between needs to expand to fill the remaining space in the browser window.
Initially, I attempted to use CSS flexbox to achieve this layout, but my implementation did not work as expected when I transitioned to the bootstrap environment. Despite referencing the flexbox utilities in the Bootstrap documentation, I struggled to make the content area expand dynamically.
I experimented with the align-self-stretch
property and even tried adding height:100%
styles to the containing divs, but these approaches did not yield the desired results. I also created a Plunker example based on a codeply response that seemed promising, but I encountered difficulties integrating it into my angular code.
This is a snippet of the angular component I am currently working on:
<div id="outer" class="d-flex flex-column flex-grow">
<div id="one" class="">
header content <br>
another line <br>
And another
</div>
<div id="two" class="bg-info h-100 flex-grow">
main content that I want to expand to cover remaining available height
</div>
<div id="three" class="">
footer content
</div>
</div>
Furthermore, here is the application container structure displaying the navbar and injection point:
<div class="d-flex flex-column h-100">
<nav class="navbar navbar-toggleable-md sticky-top bg-faded">
<a class="navbar-brand" href="#">
<h1 class="navbar-brand mb-0">My App</h1>
</a>
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" routerLink="/flex">My flex view</a></li>
</ul>
</nav>
<router-outlet></router-outlet>
</div>
My primary goal is to have the #two
div expand to fill the available space while keeping the #one
and #three
divs as headers and footers respectively within the content area. How can I achieve this layout effectively?