mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-09 23:57:08 +02:00
feat: Full screen menu
This commit is contained in:
4
contents/_includes/covers/full-screen-menu.njk
Normal file
4
contents/_includes/covers/full-screen-menu.njk
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<div class="full-screen-menu">
|
||||||
|
{% lines "hor", 5 %}
|
||||||
|
<button type="button" class="full-screen-menu__close"></button>
|
||||||
|
</div>
|
49
contents/full-screen-menu.md
Normal file
49
contents/full-screen-menu.md
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
layout: layouts/post.njk
|
||||||
|
title: Full screen menu
|
||||||
|
description: Create a full screen menu with CSS flexbox
|
||||||
|
keywords: css fixed, css flexbox, css menu
|
||||||
|
---
|
||||||
|
|
||||||
|
## HTML
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div class="full-screen-menu">
|
||||||
|
<!-- The navigation menu -->
|
||||||
|
<ul>
|
||||||
|
...
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- The close button -->
|
||||||
|
<button type="button" class="full-screen-menu__close"></button>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
## CSS
|
||||||
|
|
||||||
|
```css
|
||||||
|
.full-screen-menu {
|
||||||
|
/* Full screen overlay */
|
||||||
|
height: 100%;
|
||||||
|
left: 0;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
/* Center the content */
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.full-screen-menu__close {
|
||||||
|
/* Shown at top left corner */
|
||||||
|
left: 1rem;
|
||||||
|
position: absolute;
|
||||||
|
top: 1rem;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use the [close button](/close-button/) to create a button for closing the menu.
|
||||||
|
|
||||||
|
{% demo %}{% include "covers/full-screen-menu.njk" %}{% enddemo %}
|
@@ -129,6 +129,7 @@ eleventyExcludeFromCollections: true
|
|||||||
{% pattern "Circular navigation" %}{% include "covers/circular-navigation.njk" %}{% endpattern %}
|
{% pattern "Circular navigation" %}{% include "covers/circular-navigation.njk" %}{% endpattern %}
|
||||||
{% pattern "Dot navigation" %}{% include "covers/dot-navigation.njk" %}{% endpattern %}
|
{% pattern "Dot navigation" %}{% include "covers/dot-navigation.njk" %}{% endpattern %}
|
||||||
{% pattern "Drawer" %}{% include "covers/drawer.njk" %}{% endpattern %}
|
{% pattern "Drawer" %}{% include "covers/drawer.njk" %}{% endpattern %}
|
||||||
|
{% pattern "Full screen menu" %}{% include "covers/full-screen-menu.njk" %}{% endpattern %}
|
||||||
{% pattern "Menu" %}{% include "covers/menu.njk" %}{% endpattern %}
|
{% pattern "Menu" %}{% include "covers/menu.njk" %}{% endpattern %}
|
||||||
{% pattern "Pagination" %}{% include "covers/pagination.njk" %}{% endpattern %}
|
{% pattern "Pagination" %}{% include "covers/pagination.njk" %}{% endpattern %}
|
||||||
{% pattern "Previous next buttons" %}{% include "covers/previous-next-buttons.njk" %}{% endpattern %}
|
{% pattern "Previous next buttons" %}{% include "covers/previous-next-buttons.njk" %}{% endpattern %}
|
||||||
|
@@ -1,140 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import Head from 'next/head';
|
|
||||||
|
|
||||||
import { Pattern } from '../../constants/Pattern';
|
|
||||||
import { PatternLayout } from '../../layouts/PatternLayout';
|
|
||||||
import BrowserFrame from '../../placeholders/BrowserFrame';
|
|
||||||
import Rectangle from '../../placeholders/Rectangle';
|
|
||||||
|
|
||||||
const Details: React.FC<{}> = () => {
|
|
||||||
return (
|
|
||||||
<PatternLayout pattern={Pattern.FullScreenMenu}>
|
|
||||||
<Head>
|
|
||||||
<meta name="description" content="Create a full screen menu with CSS flexbox" />
|
|
||||||
<meta name="og:description" content="Create a full screen menu with CSS flexbox" />
|
|
||||||
<meta name="twitter:description" content="Create a full screen menu with CSS flexbox" />
|
|
||||||
<meta name="keywords" content="css fixed, css flexbox, css menu" />
|
|
||||||
</Head>
|
|
||||||
<BrowserFrame
|
|
||||||
html={`
|
|
||||||
<div class="container">
|
|
||||||
<!-- The close button -->
|
|
||||||
<button class="container__close">
|
|
||||||
...
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<!-- The navigation menu -->
|
|
||||||
<ul>
|
|
||||||
...
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
`}
|
|
||||||
css={`
|
|
||||||
.container {
|
|
||||||
/* Full screen overlay */
|
|
||||||
height: 100%;
|
|
||||||
left: 0;
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
/* Center the content */
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container__close {
|
|
||||||
/* Shown at top right corner */
|
|
||||||
position: absolute;
|
|
||||||
right: 16px;
|
|
||||||
top: 16px;
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
position: 'relative',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
style={{
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
borderColor: 'transparent',
|
|
||||||
padding: 0,
|
|
||||||
position: 'absolute',
|
|
||||||
right: '16px',
|
|
||||||
top: '16px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
style={{
|
|
||||||
fill: 'none',
|
|
||||||
height: 24,
|
|
||||||
stroke: '#000',
|
|
||||||
strokeLinecap: 'round',
|
|
||||||
strokeLinejoin: 'round',
|
|
||||||
strokeWidth: 1,
|
|
||||||
width: 24,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d={`M7,16.999l10-10
|
|
||||||
M17,16.999l-10-10
|
|
||||||
M12,0.499c6.351,0,11.5,5.149,11.5,11.5s-5.149,11.5-11.5,11.5
|
|
||||||
S0.5,18.35,0.5,11.999S5.649,0.499,12,0.499z`}
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.25)',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
left: 0,
|
|
||||||
position: 'absolute',
|
|
||||||
top: 0,
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ul
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
listStyleType: 'none',
|
|
||||||
margin: 0,
|
|
||||||
padding: 0,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<li style={{ marginBottom: '16px', width: '256px' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</li>
|
|
||||||
<li style={{ marginBottom: '16px', width: '144px' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</li>
|
|
||||||
<li style={{ marginBottom: '16px', width: '128px' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</li>
|
|
||||||
<li style={{ width: '160px' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</BrowserFrame>
|
|
||||||
</PatternLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Details;
|
|
@@ -1,55 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
import Frame from '../../placeholders/Frame';
|
|
||||||
import Rectangle from '../../placeholders/Rectangle';
|
|
||||||
|
|
||||||
const Cover: React.FC<{}> = () => {
|
|
||||||
return (
|
|
||||||
<Frame>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
height: '100%',
|
|
||||||
position: 'relative',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.25)',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
left: 0,
|
|
||||||
position: 'absolute',
|
|
||||||
top: 0,
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ marginBottom: '4px', width: '60%' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<div style={{ marginBottom: '4px', width: '40%' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<div style={{ marginBottom: '4px', width: '50%' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Frame>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Cover;
|
|
@@ -46,6 +46,7 @@
|
|||||||
@import './patterns/floating-label';
|
@import './patterns/floating-label';
|
||||||
@import './patterns/folder-structure';
|
@import './patterns/folder-structure';
|
||||||
@import './patterns/full-background';
|
@import './patterns/full-background';
|
||||||
|
@import './patterns/full-screen-menu';
|
||||||
@import './patterns/holy-grail';
|
@import './patterns/holy-grail';
|
||||||
@import './patterns/initial-avatar';
|
@import './patterns/initial-avatar';
|
||||||
@import './patterns/input-addon';
|
@import './patterns/input-addon';
|
||||||
|
67
styles/patterns/_full-screen-menu.scss
Normal file
67
styles/patterns/_full-screen-menu.scss
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
.full-screen-menu {
|
||||||
|
/* Take full size */
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
/* Center the content */
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
background: #374151;
|
||||||
|
}
|
||||||
|
|
||||||
|
.full-screen-menu__close {
|
||||||
|
left: 0.5rem;
|
||||||
|
position: absolute;
|
||||||
|
top: 0.5rem;
|
||||||
|
|
||||||
|
/* Reset */
|
||||||
|
background-color: transparent;
|
||||||
|
border-color: transparent;
|
||||||
|
|
||||||
|
/* Cursor */
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
/* Size */
|
||||||
|
height: 1rem;
|
||||||
|
width: 1rem;
|
||||||
|
|
||||||
|
&:before,
|
||||||
|
&:after {
|
||||||
|
content: '';
|
||||||
|
/* Background color */
|
||||||
|
background-color: #d1d5db;
|
||||||
|
|
||||||
|
/* Position */
|
||||||
|
position: absolute;
|
||||||
|
|
||||||
|
/* Size */
|
||||||
|
height: 1px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
/* Position */
|
||||||
|
left: 0px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(0%, -50%) rotate(45deg);
|
||||||
|
|
||||||
|
/* Size */
|
||||||
|
height: 1px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:after {
|
||||||
|
/* Position */
|
||||||
|
left: 50%;
|
||||||
|
top: 0px;
|
||||||
|
transform: translate(-50%, 0%) rotate(45deg);
|
||||||
|
|
||||||
|
/* Size */
|
||||||
|
height: 100%;
|
||||||
|
width: 1px;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user