mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-06 14:16:50 +02:00
feat: Separator
This commit is contained in:
4
contents/_includes/patterns/separator.njk
Normal file
4
contents/_includes/patterns/separator.njk
Normal file
@@ -0,0 +1,4 @@
|
||||
<div class="separator">
|
||||
<div class="separator__content">{% rectangle "hor", "sm", 100 %}</div>
|
||||
<div class="separator__separator"></div>
|
||||
</div>
|
@@ -229,6 +229,12 @@ eleventyExcludeFromCollections: true
|
||||
<div class="pattern__title">Ribbon</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pattern__item">
|
||||
<a class="pattern__link" href="/separator/">
|
||||
<div class="pattern__cover">{% include "patterns/separator.njk" %}</div>
|
||||
<div class="pattern__title">Separator</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pattern__item">
|
||||
<a class="pattern__link" href="/video-background/">
|
||||
<div class="pattern__cover">{% include "patterns/video-background.njk" %}</div>
|
||||
|
60
contents/separator.md
Normal file
60
contents/separator.md
Normal file
@@ -0,0 +1,60 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Separator
|
||||
description: Create a separator with CSS flexbox
|
||||
keywords: css divider, css flexbox, css separator
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="separator">
|
||||
<!-- Text -->
|
||||
<div class="separator__content">
|
||||
...
|
||||
</div>
|
||||
|
||||
<!-- Separator line -->
|
||||
<div class="separator__separator"></div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.separator {
|
||||
/* Content is centered horizontally */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
/* Used to set the position of text */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.separator__content {
|
||||
/* We won't see the separator line */
|
||||
background: #fff;
|
||||
|
||||
/* Displayed at the center of separator */
|
||||
left: 50%;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
/* Spacing */
|
||||
padding: 0 0.25rem;
|
||||
|
||||
/* Demo */
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.separator__separator {
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}
|
||||
{% include "patterns/separator.njk" %}
|
||||
{% enddemo %}
|
@@ -1,104 +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.Separator}>
|
||||
<Head>
|
||||
<meta name="description" content="Create a separator with CSS flexbox" />
|
||||
<meta name="og:description" content="Create a separator with CSS flexbox" />
|
||||
<meta name="twitter:description" content="Create a separator with CSS flexbox" />
|
||||
<meta name="keywords" content="css divider, css flexbox, css separator" />
|
||||
</Head>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div class="container">
|
||||
<!-- Text -->
|
||||
<div class="container__content">
|
||||
...
|
||||
</div>
|
||||
|
||||
<!-- Separator line -->
|
||||
<div class="container__separator"></div>
|
||||
</div>
|
||||
`}
|
||||
css={`
|
||||
.container {
|
||||
/* Content is centered horizontally */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
/* Used to set the position of text */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.container__content {
|
||||
/* We won't see the separator line */
|
||||
background: #fff;
|
||||
|
||||
/* Displayed at the center of container */
|
||||
left: 50%;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.container__separator {
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
position: 'relative',
|
||||
width: '60%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: '#FFF',
|
||||
left: '50%',
|
||||
padding: '0 8px',
|
||||
position: 'absolute',
|
||||
top: '50%',
|
||||
transform: 'translate(-50%, -50%)',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '128px' }}>
|
||||
<Rectangle height={16} />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
height: '1px',
|
||||
width: '100%',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
</PatternLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@@ -1,43 +0,0 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import Frame from '../../placeholders/Frame';
|
||||
import Line from '../../placeholders/Line';
|
||||
import Rectangle from '../../placeholders/Rectangle';
|
||||
|
||||
const Cover: React.FC<{}> = () => {
|
||||
return (
|
||||
<Frame>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
height: '16px',
|
||||
width: '80%',
|
||||
}}
|
||||
>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ margin: '0 4px', width: '25%' }}>
|
||||
<Rectangle />
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Line />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -47,6 +47,7 @@
|
||||
@import './patterns/property-list';
|
||||
@import './patterns/questions-and-answers';
|
||||
@import './patterns/ribbon';
|
||||
@import './patterns/separator';
|
||||
@import './patterns/triangle-buttons';
|
||||
@import './patterns/video-background';
|
||||
@import './patterns/voting';
|
||||
|
34
styles/patterns/_separator.scss
Normal file
34
styles/patterns/_separator.scss
Normal file
@@ -0,0 +1,34 @@
|
||||
.separator {
|
||||
/* Content is centered horizontally */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
/* Used to set the position of text */
|
||||
position: relative;
|
||||
|
||||
/* Demo */
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.separator__content {
|
||||
/* We won't see the separator line */
|
||||
background: #fff;
|
||||
|
||||
/* Displayed at the center of separator */
|
||||
left: 50%;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
/* Spacing */
|
||||
padding: 0 0.25rem;
|
||||
|
||||
/* Demo */
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.separator__separator {
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
}
|
Reference in New Issue
Block a user