I've just started learning about reactjs and bulma.css. I'm trying to make a <footer>
to stick to the bottom of the page using bulma's flexbox since I want to avoid writing my own css rules.
I already installed bulma using npm and imported bulma.css in the index.js like this
import "bulma/css/bulma.css";
but my code below still makes the <footer>
to stick under the header..
<div className='container'>
<header className='has-text-centered'>
<h1>My Store</h1>
</header>
<div>
<h2>Dashboard Title</h2>
</div>
<footer className="has-text-centered is-flex-align-items-flex-end">
<small>
<span>Copyright @2022</span>
<br />
</small>
<a href="/">About</a>
</footer>
</div>
CodePudding user response:
The straightforward-bulma way would look something like:
Make sure the body and html are the full page height
Since this is every project-dependent, I've used the classicbody { height: 100vh; }
for nowThe same for the
container
, it needs to be enlarged. Using theis-fullheight
from thehero
elements can be used (note: Consider using a hero instead of the container)Give the footer a
mt-auto
which is short formargin-top: auto
. This will force the footer to stick to the bottom of the page
html, body { height: 100vh; }
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
<div class='container hero is-fullheight'>
<header class='has-text-centered'>
<h1>My Store</h1>
</header>
<div>
<h2>Dashboard Title</h2>
</div>
<footer >
<small>
<span>Copyright @2022</span>
<br />
</small>
<a href="/">About</a>
</footer>
</div>