mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-07 06:37:01 +02:00
feat: Sticky footer
This commit is contained in:
5
contents/_includes/patterns/sticky-footer.njk
Normal file
5
contents/_includes/patterns/sticky-footer.njk
Normal file
@@ -0,0 +1,5 @@
|
||||
<div class="sticky-footer">
|
||||
<div class="sticky-footer__header">{% rectangle %}</div>
|
||||
<div class="sticky-footer__main">{% lines "hor", 5 %}</div>
|
||||
<div class="sticky-footer__footer">{% rectangle %}</div>
|
||||
</div>
|
@@ -116,6 +116,7 @@ eleventyExcludeFromCollections: true
|
||||
{% pattern "Sidebar" %}{% include "patterns/sidebar.njk" %}{% endpattern %}
|
||||
{% pattern "Simple grid" %}{% include "patterns/simple-grid.njk" %}{% endpattern %}
|
||||
{% pattern "Split screen" %}{% include "patterns/split-screen.njk" %}{% endpattern %}
|
||||
{% pattern "Sticky footer" %}{% include "patterns/sticky-footer.njk" %}{% endpattern %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
45
contents/sticky-footer.md
Normal file
45
contents/sticky-footer.md
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Sticky footer
|
||||
description: Create a sticky footer with CSS flexbox
|
||||
keywords: css flexbox, css layout, css sticky, css sticky footer
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="sticky-footer">
|
||||
<header class="sticky-footer__header">
|
||||
...
|
||||
</header>
|
||||
<main class="sticky-footer__main">
|
||||
...
|
||||
</main>
|
||||
<footer class="sticky-footer__footer">
|
||||
...
|
||||
</footer>
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.sticky-footer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.sticky-footer__header,
|
||||
.sticky-footer__footer {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sticky-footer__main {
|
||||
flex-grow: 1;
|
||||
}
|
||||
```
|
||||
|
||||
The footer always sticks to the bottom if the main content is short.
|
||||
|
||||
{% demo %}{% include "patterns/sticky-footer.njk" %}{% enddemo %}
|
@@ -1,91 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import Head from 'next/head';
|
||||
|
||||
import { Pattern } from '../../constants/Pattern';
|
||||
import { PatternLayout } from '../../layouts/PatternLayout';
|
||||
import Block from '../../placeholders/Block';
|
||||
import BrowserFrame from '../../placeholders/BrowserFrame';
|
||||
import Rectangle from '../../placeholders/Rectangle';
|
||||
|
||||
const Details: React.FC<{}> = () => {
|
||||
return (
|
||||
<PatternLayout pattern={Pattern.StickyFooter}>
|
||||
<Head>
|
||||
<meta name="description" content="Create a sticky footer with CSS flexbox" />
|
||||
<meta name="og:description" content="Create a sticky footer with CSS flexbox" />
|
||||
<meta name="twitter:description" content="Create a sticky footer with CSS flexbox" />
|
||||
<meta name="keywords" content="css flexbox, css layout, css sticky, css sticky footer" />
|
||||
</Head>
|
||||
<div style={{ lineHeight: 1.5, marginBottom: '16px' }}>
|
||||
The footer always sticks to the bottom if the main content is short.
|
||||
</div>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div class="container">
|
||||
<header class="container__header">
|
||||
...
|
||||
</header>
|
||||
<main class="container__main">
|
||||
...
|
||||
</main>
|
||||
<footer class="container__footer">
|
||||
...
|
||||
</footer>
|
||||
</div>
|
||||
`}
|
||||
css={`
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.container__header,
|
||||
.container__footer {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.container__main {
|
||||
flex-grow: 1;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
borderBottom: '1px solid #d1d5db',
|
||||
flexShrink: 0,
|
||||
padding: '16px',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '50%' }}>
|
||||
<Rectangle />
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ flexGrow: 1, padding: '16px' }}>
|
||||
<Block numberOfBlocks={20} />
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
borderTop: '1px solid #d1d5db',
|
||||
flexShrink: 0,
|
||||
padding: '16px',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '40%' }}>
|
||||
<Rectangle />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
</PatternLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@@ -1,86 +0,0 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import Frame from '../../placeholders/Frame';
|
||||
import Line from '../../placeholders/Line';
|
||||
|
||||
const Cover: React.FC<{}> = () => {
|
||||
return (
|
||||
<Frame>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
borderBottom: '1px solid #d1d5db',
|
||||
borderRight: '4px solid #d1d5db',
|
||||
display: 'flex',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
padding: '8px',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '16px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ marginLeft: 'auto', width: '16px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ marginLeft: '4px', width: '16px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
borderRight: '4px solid #d1d5db',
|
||||
flex: 1,
|
||||
}}
|
||||
>
|
||||
<div style={{ padding: '8px' }}>
|
||||
<div style={{ marginBottom: '8px', width: '64px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ marginBottom: '8px', width: '64px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ width: '32px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Line />
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
padding: '8px',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '16px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ marginLeft: '4px', width: '16px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ marginLeft: '4px', width: '16px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -80,6 +80,7 @@
|
||||
@import './patterns/statistic';
|
||||
@import './patterns/status-light';
|
||||
@import './patterns/stepper-input';
|
||||
@import './patterns/sticky-footer';
|
||||
@import './patterns/sticky-table-column';
|
||||
@import './patterns/sticky-table-headers';
|
||||
@import './patterns/switch';
|
||||
|
27
styles/patterns/_sticky-footer.scss
Normal file
27
styles/patterns/_sticky-footer.scss
Normal file
@@ -0,0 +1,27 @@
|
||||
.sticky-footer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
|
||||
/* Demo */
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 0.25rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sticky-footer__header,
|
||||
.sticky-footer__footer {
|
||||
flex-shrink: 0;
|
||||
|
||||
/* Demo */
|
||||
padding: 0.25rem;
|
||||
}
|
||||
|
||||
.sticky-footer__main {
|
||||
flex-grow: 1;
|
||||
|
||||
/* Demo */
|
||||
border-top: 1px solid #d1d5db;
|
||||
border-bottom: 1px solid #d1d5db;
|
||||
padding: 0.25rem;
|
||||
}
|
Reference in New Issue
Block a user