I currently have some code that runs fine but no matter what I do, I cannot get the footer to stick to the bottom of the screen. Is it possible for anyone who can come up with a quick solution for this to add it to jsx code?
function Header() {
return (
<header>
<nav className="nav">
<img src="./react-logo.png" className="nav-logo" />
<ul className="nav-items">
<li>Pricing</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
</header>
)
}
function Footer() {
return (
<footer>
<small>© 2021 Ziroll development. All rights reserved.</small>
</footer>
)
}
function MainContent() {
return (
<div>
<h1>Reasons I'm excited to learn React</h1>
<ol>
<li>It's a popular library, so I'll be
able to fit in with the cool kids!</li>
<li>I'm more likely to get a job as a developer
if I know React</li>
</ol>
</div>
)
}
function Page() {
return (
<div>
<Header />
<MainContent />
<Footer />
</div>
)
}
ReactDOM.render(<Page />, document.getElementById("root"))
3
Answers
Try this. Give the footer a position of absolute, bottom 0. See if it works. You can use inline-styles if you prefer it.
you can do it with inline css like:
or create a css file:
You can simply add the bellow styles to your code and change the
dev
structure.