I am using Bootstrap 4, and I have a pretty complex footer:
...that adjusts its height dynamically. This is a PHP application, so the content in the center of the screen changes. When the content is bigger than the screen, it pushes the footer to the bottom as desired. However, I have scenarios where the content is pretty small and then the footer has whitespace underneath it.
I also have a header.
How can I use CSS to adjust the bootstrap classes so that if (and only if) the height of the content plus the height of the footer is not 100% of the viewport height, it expands the content so that it is?
Here is what it looks like currently:
As you can see, the whitespace is at the bottom of the screen below the footer. I do not want to make a sticky footer and scroll in the middle, I just want the footer to be at the bottom of the screen if the content in between the header and footer isn't taking up the remaining height.
Everything I've seen so far requires you to fix the height of the footer but then I fear the footer will not respond properly on different screen sizes.
Here is my general HTML layout, with bootstrap classes:
<body>
<!--Navbar-->
<nav class="navbar navbar-expand-lg navbar-dark fixed-top top-nav-collapse">
<div class="container">
<!-- Navbar brand -->
<a class="navbar-brand" href="https://dization.com/" target="_blank"><img src="../public/images/cropped-logo_white.png" width="185" height="58px"></a>
<!-- Collapse button -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#basicExampleNav" aria-controls="basicExampleNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>
<!--/.Navbar-->
<!--Main layout-->
<main class="mt-4">
<div class="container">
<div class="row justify-content-center" id="divCardSignUp">
<div class="col-lg-12">
<div class="card my-5">
<!-- Logo -->
<div class="card-header pt-4 pb-4 text-center bg-light">
<span><img src="../public/images/Logo-no-text.png" alt="" height="30"></span>
</div>
<div class="card-body p-4">
<!-- boot strap rows and cols divs in here -->
</div>
</div>
<!-- end card -->
</div> <!-- end col -->
</div>
</div>
</main>
<!--Main layout-->
<!-- Footer -->
<footer class="page-footer font-small unique-color-dark mt-2">
<!-- Social buttons -->
<div class="primary-color">
<div class="container"></div>
</div>
<!-- Social buttons -->
<!--Footer Links-->
<div class="container mt-5 mb-4 text-center text-md-left">
<div class="row mt-3"></div>
</div>
<!--/.Footer Links-->
<!-- Copyright -->
<div class="footer-copyright text-center py-3"></div>
<!-- Copyright -->
</footer>
<!-- Footer -->
</body>
Here is the only custom CSS I added to the page:
html,
body,
header {
height: 100%;
}
body {
padding-top: 70px;
}
Any help would be appreciated.
Thanks.