1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-06 14:16:50 +02:00

feat: Corner curved background pattern

This commit is contained in:
Phuoc Nguyen
2022-09-19 14:29:07 +07:00
parent 2c3361a6c9
commit 870ae88df6
7 changed files with 62 additions and 91 deletions

View File

@@ -0,0 +1,3 @@
<div class="curved-background">
<div class="curved-background__curved"></div>
</div>

View File

@@ -0,0 +1,38 @@
---
layout: layouts/post.njk
title: Curved background
description: Create an element with curved background
keywords: css border radius, css curved background
---
## HTML
```html
<div class="curved-background">
<div class="curved-background__curved"></div>
</div>
```
## CSS
```css
.curved-background__curved {
/* Background color */
background-color: rgba(0, 0, 0, 0.3);
/* You can use gradient background color such as */
/* background: linear-gradient(rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.1) 100%); */
/* Curved corners */
border-bottom-left-radius: 50% 40%;
border-bottom-right-radius: 50% 40%;
/* Size */
height: 50%;
width: 100%;
}
```
{% demo %}
{% include "patterns/curved-background.njk" %}
{% enddemo %}

View File

@@ -85,6 +85,12 @@ eleventyExcludeFromCollections: true
<div class="pattern__title">Corner ribbon</div>
</a>
</div>
<div class="pattern__item">
<a class="pattern__link" href="/curved-background/">
<div class="pattern__cover">{% include "patterns/curved-background.njk" %}</div>
<div class="pattern__title">Curved background</div>
</a>
</div>
</div>
</div>

View File

@@ -1,63 +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 BrowserFrame from '../../placeholders/BrowserFrame';
const Details: React.FC<{}> = () => {
return (
<PatternLayout pattern={Pattern.CurvedBackground}>
<Head>
<meta name="description" content="Create an element with curved background" />
<meta name="og:description" content="Create an element with curved background" />
<meta name="twitter:description" content="Create an element with curved background" />
<meta name="keywords" content="css border radius, css curved background" />
</Head>
<BrowserFrame
html={`
<div class="container">
...
</div>
`}
css={`
.container {
/* Background color */
background-color: rgba(0, 0, 0, 0.3);
/* You can use gradient background color such as
background: linear-gradient(rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.1) 100%); */
/* Curved corners */
border-bottom-left-radius: 50% 40%;
border-bottom-right-radius: 50% 40%;
}
`}
>
<div
style={{
height: '100%',
padding: '8px',
}}
>
<div
style={{
backgroundColor: 'rgba(0, 0, 0, 0.3)',
borderBottomLeftRadius: '50% 40%',
borderBottomRightRadius: '50% 40%',
height: '50%',
width: '100%',
}}
/>
</div>
</BrowserFrame>
<Spacer size="extraLarge" />
<RelatedPatterns patterns={[Pattern.DiagonalSection]} />
</PatternLayout>
);
};
export default Details;

View File

@@ -1,28 +0,0 @@
import * as React from 'react';
import Frame from '../../placeholders/Frame';
const Cover: React.FC<{}> = () => {
return (
<Frame>
<div
style={{
height: '100%',
padding: '8px',
}}
>
<div
style={{
backgroundColor: 'rgba(0, 0, 0, 0.3)',
borderBottomLeftRadius: '50% 40%',
borderBottomRightRadius: '50% 40%',
height: '50%',
width: '100%',
}}
/>
</div>
</Frame>
);
};
export default Cover;

View File

@@ -23,6 +23,7 @@
@import './patterns/concave-corners';
@import './patterns/cookie-banner';
@import './patterns/corner-ribbon';
@import './patterns/curved-background';
// Placeholders
@import './placeholders/circle';

View File

@@ -0,0 +1,14 @@
.curved-background {
border: 1px solid rgba(0,0,0,.3);
border-radius: 0.25rem;
height: 100%;
width: 100%;
}
.curved-background__curved {
background-color: rgba(0, 0, 0, 0.3);
border-bottom-left-radius: 50% 40%;
border-bottom-right-radius: 50% 40%;
height: 50%;
width: 100%;
}