mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-06 14:16:50 +02:00
feat: Full background
This commit is contained in:
3
contents/_includes/patterns/full-background.njk
Normal file
3
contents/_includes/patterns/full-background.njk
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="full-background">
|
||||
{% lines "hor", 10 %}
|
||||
</div>
|
37
contents/full-background.md
Normal file
37
contents/full-background.md
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Full background
|
||||
description: Create a full background element with CSS
|
||||
keywords: css background size cover, css full background
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="full-background">
|
||||
...
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.full-background {
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
|
||||
/* Take full size */
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
|
||||
/* Background */
|
||||
background: url('/assets/full-background.jpeg') center center / cover no-repeat;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}
|
||||
{% include "patterns/full-background.njk" %}
|
||||
{% enddemo %}
|
@@ -151,6 +151,12 @@ eleventyExcludeFromCollections: true
|
||||
<div class="pattern__title">Fixed at side</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pattern__item">
|
||||
<a class="pattern__link" href="/full-background/">
|
||||
<div class="pattern__cover">{% include "patterns/full-background.njk" %}</div>
|
||||
<div class="pattern__title">Full background</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -1,75 +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.FullBackground}>
|
||||
<Head>
|
||||
<meta name="description" content="Create a full background element with CSS" />
|
||||
<meta name="og:description" content="Create a full background element with CSS" />
|
||||
<meta name="twitter:description" content="Create a full background element with CSS" />
|
||||
<meta name="keywords" content="css background size cover, css full background" />
|
||||
</Head>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div class="container">
|
||||
...
|
||||
</div>
|
||||
`}
|
||||
css={`
|
||||
.container {
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
|
||||
/* Take full size */
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
|
||||
/* Background */
|
||||
background: url('/assets/full-background.jpeg') center center / cover no-repeat;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
background: 'url("/assets/full-background.jpeg") center center / cover no-repeat',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '250px' }}>
|
||||
<Block backgroundColor="#fff" justify="center" numberOfBlocks={10} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
<Spacer size="extraLarge" />
|
||||
<RelatedPatterns patterns={[Pattern.VideoBackground]} />
|
||||
</PatternLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@@ -1,34 +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={{
|
||||
alignItems: 'center',
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.25)',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div style={{ marginBottom: '4px', width: '80%' }}>
|
||||
<Line backgroundColor="#fff" />
|
||||
</div>
|
||||
<div style={{ marginBottom: '4px', width: '60%' }}>
|
||||
<Line backgroundColor="#fff" />
|
||||
</div>
|
||||
<div style={{ width: '40%' }}>
|
||||
<Line backgroundColor="#fff" />
|
||||
</div>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -34,6 +34,7 @@
|
||||
@import './patterns/feature-list';
|
||||
@import './patterns/fixed-at-corner';
|
||||
@import './patterns/fixed-at-side';
|
||||
@import './patterns/full-background';
|
||||
|
||||
// Placeholders
|
||||
@import './placeholders/circle';
|
||||
|
13
styles/patterns/_full-background.scss
Normal file
13
styles/patterns/_full-background.scss
Normal file
@@ -0,0 +1,13 @@
|
||||
.full-background {
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
|
||||
/* Take full size */
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
background: url('/assets/full-background.jpeg') center center / cover no-repeat;
|
||||
}
|
Reference in New Issue
Block a user