My aim is to use % instead of Vh when im dealing with sticky footer in react js.
I tried to use % but the footer won’t stick to the bottom.
I set up a simple react app to test this so if anyone knows how to fix it please help me.
Please notice i don’t want to apply vh so it can also be mobile friendly at the same time and avoiding fixed heights such as vh.
/*My code */
**APP js **/
/*Import Styles*/
import "./styles/App.scss";
import "./styles/Variables.scss";
/*Import the components*/
import Navigation from "./components/Navigation/Navigation";
import Showcase from "./components/Showcase/Showcase";
import Footer from "./components/Footer/Footer";
/*Components*/
const App = () => {
return (
<div className="App">
<Navigation />
<Showcase />
<Footer />
</div>
)
}
export default App;
/**App scss **/
html {
height: 100%;
background-color: gray;
}
.App {
display: flex;
flex-direction: column;
min-height: 100%;
}
/*Footer scss**/
.footer {
min-height: auto;
border: 1px solid black;
}
/**showcase scss **/
is Empty not styles applied.
`
2
Answers
should work when wrapping all content inside a div like in App.js:
I can’t test your code but try:
.footer { margin-top: auto; }
Or give Showcase a
flex-grow: 1;
.