mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-08 07:07:15 +02:00
feat: Add Diagonal section pattern
This commit is contained in:
3
contents/_includes/patterns/diagonal-section.njk
Normal file
3
contents/_includes/patterns/diagonal-section.njk
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<div class="diagonal-section">
|
||||||
|
<div class="diagonal-section__diagonal"></div>
|
||||||
|
</div>
|
51
contents/diagonal-section.md
Normal file
51
contents/diagonal-section.md
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
---
|
||||||
|
layout: layouts/post.njk
|
||||||
|
title: Diagonal section
|
||||||
|
description: Create a diagonal section with CSS
|
||||||
|
keywords: css diagonal section, css transform skew
|
||||||
|
---
|
||||||
|
|
||||||
|
## HTML
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div class="diagonal-section">
|
||||||
|
<!-- The diagonal area -->
|
||||||
|
<div class="diagonal-section__diagonal"></div>
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
## CSS
|
||||||
|
|
||||||
|
```css
|
||||||
|
.diagonal-section {
|
||||||
|
/* Used to position the diagonal area */
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.diagonal-section__diagonal {
|
||||||
|
/* Absolute position */
|
||||||
|
left: 0px;
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
|
||||||
|
/* Take full size */
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
/* Create diagonal sides */
|
||||||
|
transform: skewY(-5deg);
|
||||||
|
|
||||||
|
/* Background color */
|
||||||
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
|
|
||||||
|
/* Displayed under the main content */
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{% demo %}
|
||||||
|
{% include "patterns/diagonal-section.njk" %}
|
||||||
|
{% enddemo %}
|
@@ -91,6 +91,12 @@ eleventyExcludeFromCollections: true
|
|||||||
<div class="pattern__title">Curved background</div>
|
<div class="pattern__title">Curved background</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pattern__item">
|
||||||
|
<a class="pattern__link" href="/diagonal-section/">
|
||||||
|
<div class="pattern__cover">{% include "patterns/diagonal-section.njk" %}</div>
|
||||||
|
<div class="pattern__title">Diagonal section</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -1,101 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import Head from 'next/head';
|
|
||||||
import { Spacer } from '@1milligram/design';
|
|
||||||
|
|
||||||
import { RelatedPatterns } from '../../components/RelatedPatterns';
|
|
||||||
import { Pattern } from '../../constants/Pattern';
|
|
||||||
import { PatternLayout } from '../../layouts/PatternLayout';
|
|
||||||
import Block from '../../placeholders/Block';
|
|
||||||
import BrowserFrame from '../../placeholders/BrowserFrame';
|
|
||||||
|
|
||||||
const Details: React.FC<{}> = () => {
|
|
||||||
return (
|
|
||||||
<PatternLayout pattern={Pattern.DiagonalSection}>
|
|
||||||
<Head>
|
|
||||||
<meta name="description" content="Create a diagonal section with CSS" />
|
|
||||||
<meta name="og:description" content="Create a diagonal section with CSS" />
|
|
||||||
<meta name="twitter:description" content="Create a diagonal section with CSS" />
|
|
||||||
<meta name="keywords" content="css diagonal section, css transform skew" />
|
|
||||||
</Head>
|
|
||||||
<BrowserFrame
|
|
||||||
html={`
|
|
||||||
<div class="container">
|
|
||||||
<!-- The diagonal area -->
|
|
||||||
<div class="container__diagonal"></div>
|
|
||||||
|
|
||||||
<!-- Content -->
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
`}
|
|
||||||
css={`
|
|
||||||
.container {
|
|
||||||
/* Used to position the diagonal area */
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container__diagonal {
|
|
||||||
/* Absolute position */
|
|
||||||
left: 0px;
|
|
||||||
position: absolute;
|
|
||||||
top: 0px;
|
|
||||||
|
|
||||||
/* Take full size */
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
/* Create diagonal sides */
|
|
||||||
transform: skewY(-5deg);
|
|
||||||
|
|
||||||
/* Background color */
|
|
||||||
background-color: rgba(0, 0, 0, 0.3);
|
|
||||||
|
|
||||||
/* Displayed under the main content */
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '200px',
|
|
||||||
justifyContent: 'center',
|
|
||||||
position: 'relative',
|
|
||||||
width: '75%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
|
||||||
height: '100%',
|
|
||||||
left: 0,
|
|
||||||
position: 'absolute',
|
|
||||||
top: 0,
|
|
||||||
transform: 'skewY(-5deg)',
|
|
||||||
width: '100%',
|
|
||||||
zIndex: -1,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div style={{ width: '60%' }}>
|
|
||||||
<Block backgroundColor="#fff" justify="center" numberOfBlocks={5} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</BrowserFrame>
|
|
||||||
<Spacer size="extraLarge" />
|
|
||||||
<RelatedPatterns patterns={[Pattern.CurvedBackground]} />
|
|
||||||
</PatternLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Details;
|
|
@@ -1,31 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
import Frame from '../../placeholders/Frame';
|
|
||||||
|
|
||||||
const Cover: React.FC<{}> = () => {
|
|
||||||
return (
|
|
||||||
<Frame>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
|
||||||
height: '40%',
|
|
||||||
transform: 'skewY(-10deg)',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Frame>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Cover;
|
|
@@ -24,6 +24,7 @@
|
|||||||
@import './patterns/cookie-banner';
|
@import './patterns/cookie-banner';
|
||||||
@import './patterns/corner-ribbon';
|
@import './patterns/corner-ribbon';
|
||||||
@import './patterns/curved-background';
|
@import './patterns/curved-background';
|
||||||
|
@import './patterns/diagonal-section';
|
||||||
|
|
||||||
// Placeholders
|
// Placeholders
|
||||||
@import './placeholders/circle';
|
@import './placeholders/circle';
|
||||||
|
24
styles/patterns/_diagonal-section.scss
Normal file
24
styles/patterns/_diagonal-section.scss
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
.diagonal-section {
|
||||||
|
/* Used to position the diagonal area */
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.diagonal-section__diagonal {
|
||||||
|
/* Absolute position */
|
||||||
|
left: 0px;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
|
||||||
|
/* Take full size */
|
||||||
|
height: 2rem;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
/* Create diagonal sides */
|
||||||
|
transform: translate(0, -50%) skewY(-15deg);
|
||||||
|
|
||||||
|
/* Background color */
|
||||||
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
Reference in New Issue
Block a user