mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-09 15:46:55 +02:00
Add sticky footer layout
This commit is contained in:
@@ -3,6 +3,7 @@ import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
|
||||
|
||||
import Home from './Home';
|
||||
import Centering from './layouts/Centering';
|
||||
import StickyFooter from './layouts/StickyFooter';
|
||||
|
||||
const App = () => {
|
||||
return (
|
||||
@@ -10,6 +11,7 @@ const App = () => {
|
||||
<Switch>
|
||||
<Route exact={true} path='/'><Home /></Route>
|
||||
<Route exact={true} path='/centering'><Centering /></Route>
|
||||
<Route exact={true} path='/sticky-footer'><StickyFooter /></Route>
|
||||
</Switch>
|
||||
</Router>
|
||||
);
|
||||
|
@@ -15,7 +15,7 @@ const Home = () => {
|
||||
|
||||
<div className="flex flex-wrap justify-between">
|
||||
<div className="w-30">
|
||||
<Link to="/centering" className="link flex flex-column items-center justify-center bg-black-05 br2 pa3">
|
||||
<Link to="/sticky-footer" className="link flex flex-column items-center justify-center bg-black-05 br2 pa3">
|
||||
<StickyFooterCover />
|
||||
<h4 className="f4 mv0 pv3">Sticky footer</h4>
|
||||
</Link>
|
||||
|
57
client/layouts/StickyFooter.jsx
Normal file
57
client/layouts/StickyFooter.jsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import React from 'react';
|
||||
|
||||
import DetailsLayout from '../DetailsLayout';
|
||||
import BrowserFrame from '../placeholders/BrowserFrame';
|
||||
import SampleCode from '../SampleCode';
|
||||
import useDocumentTitle from '../useDocumentTitle';
|
||||
|
||||
const StickyFooter = () => {
|
||||
useDocumentTitle('CSS Layout ∙ Sticky footer');
|
||||
|
||||
return (
|
||||
<DetailsLayout name="Sticky footer">
|
||||
<div className="lh-copy mb3">
|
||||
The footer is always sticky at the bottom if the main content is short.
|
||||
</div>
|
||||
<BrowserFrame
|
||||
content={
|
||||
<div className="h-100 flex flex-column ba b--black-30 bw1">
|
||||
<div className="flex-shrink-0 bb b--black-30 bw1 pa3">
|
||||
Header
|
||||
</div>
|
||||
<div className="flex-grow-1 pa3">
|
||||
Content
|
||||
</div>
|
||||
<div className="flex-shrink-0 bt b--black-30 bw1 pa3">
|
||||
Footer
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
source={
|
||||
<SampleCode
|
||||
lang="html"
|
||||
code={`
|
||||
<div style="
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: '100%';
|
||||
">
|
||||
<header style="flex-shrink: 0;">
|
||||
...
|
||||
</header>
|
||||
<main style="flex-grow: 1;">
|
||||
...
|
||||
</main>
|
||||
<footer style="flex-shrink: 0;">
|
||||
...
|
||||
</footer>
|
||||
</div>
|
||||
`}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</DetailsLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default StickyFooter;
|
Reference in New Issue
Block a user