mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-06 14:16:50 +02:00
feat: Three dimensions card
This commit is contained in:
2
contents/_includes/patterns/three-dimensions-card.njk
Normal file
2
contents/_includes/patterns/three-dimensions-card.njk
Normal file
@@ -0,0 +1,2 @@
|
||||
<div class="three-dimensions-card">
|
||||
</div>
|
@@ -265,6 +265,12 @@ eleventyExcludeFromCollections: true
|
||||
<div class="pattern__title">Teardrop</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pattern__item">
|
||||
<a class="pattern__link" href="/three-dimensions-card/">
|
||||
<div class="pattern__cover">{% include "patterns/three-dimensions-card.njk" %}</div>
|
||||
<div class="pattern__title">Three dimensions card</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pattern__item">
|
||||
<a class="pattern__link" href="/video-background/">
|
||||
<div class="pattern__cover">{% include "patterns/video-background.njk" %}</div>
|
||||
|
64
contents/three-dimensions-card.md
Normal file
64
contents/three-dimensions-card.md
Normal file
@@ -0,0 +1,64 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Three dimensions card
|
||||
description: Create a 3D card with CSS
|
||||
keywords: css 3D card
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="three-dimensions-card">
|
||||
...
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
:root {
|
||||
--three-dimensions-card-left-side-width: 1rem;
|
||||
}
|
||||
|
||||
.three-dimensions-card {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* The left side */
|
||||
.three-dimensions-card::before {
|
||||
background: #d1d5db;
|
||||
content: '';
|
||||
|
||||
/* Position */
|
||||
top: var(--three-dimensions-card-left-side-width);
|
||||
left: 0px;
|
||||
position: absolute;
|
||||
transform: translate(-100%, 0) skewY(-45deg);
|
||||
transform-origin: left top;
|
||||
|
||||
/* Size */
|
||||
height: 100%;
|
||||
width: var(--three-dimensions-card-left-side-width);
|
||||
}
|
||||
|
||||
/* The bottom side */
|
||||
.three-dimensions-card::after {
|
||||
background: #d1d5db;
|
||||
content: '';
|
||||
|
||||
/* Position */
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
position: absolute;
|
||||
transform: translate(0, 100%) skewX(-45deg);
|
||||
transform-origin: left top;
|
||||
|
||||
/* Size */
|
||||
height: var(--three-dimensions-card-left-side-width);
|
||||
width: 100%;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}
|
||||
{% include "patterns/three-dimensions-card.njk" %}
|
||||
{% enddemo %}
|
@@ -1,96 +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.ThreeDimensionsCard}>
|
||||
<Head>
|
||||
<meta name="description" content="Create a 3D card with CSS" />
|
||||
<meta name="og:description" content="Create a 3D card with CSS" />
|
||||
<meta name="twitter:description" content="Create a 3D card with CSS" />
|
||||
<meta name="keywords" content="css 3D card" />
|
||||
</Head>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div class="three-dimensions-card">
|
||||
...
|
||||
</div>
|
||||
`}
|
||||
css={`
|
||||
:root {
|
||||
--three-dimensions-card-left-side-width: 1rem;
|
||||
}
|
||||
|
||||
.three-dimensions-card {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* The left side */
|
||||
.three-dimensions-card::before {
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
content: '';
|
||||
|
||||
/* Position */
|
||||
top: var(--three-dimensions-card-left-side-width);
|
||||
left: 0px;
|
||||
position: absolute;
|
||||
transform: translate(-100%, 0) skewY(-45deg);
|
||||
transform-origin: left top;
|
||||
|
||||
/* Size */
|
||||
height: 100%;
|
||||
width: var(--three-dimensions-card-left-side-width);
|
||||
}
|
||||
|
||||
/* The bottom side */
|
||||
.three-dimensions-card::after {
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
content: '';
|
||||
|
||||
/* Position */
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
position: absolute;
|
||||
transform: translate(0, 100%) skewX(-45deg);
|
||||
transform-origin: left top;
|
||||
|
||||
/* Size */
|
||||
height: var(--three-dimensions-card-left-side-width);
|
||||
width: 100%;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div className="three-dimensions-card">
|
||||
<div
|
||||
style={{
|
||||
border: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
height: '8rem',
|
||||
width: '16rem',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
|
||||
<Spacer size="extraLarge" />
|
||||
<RelatedPatterns patterns={[Pattern.Card, Pattern.LayeredCard, Pattern.StackedCards]} />
|
||||
</PatternLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@@ -1,55 +0,0 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import Frame from '../../placeholders/Frame';
|
||||
|
||||
const Cover: React.FC<{}> = () => {
|
||||
return (
|
||||
<Frame>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '1.5rem',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
border: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
height: '2rem',
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
background: 'rgba(0, 0, 0, 0.3)',
|
||||
height: '100%',
|
||||
top: '0.5rem',
|
||||
left: 0,
|
||||
position: 'absolute',
|
||||
transform: 'translate(-100%, 0) skewY(-45deg)',
|
||||
transformOrigin: 'top left',
|
||||
width: '0.5rem',
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
background: 'rgba(0, 0, 0, 0.3)',
|
||||
bottom: 0,
|
||||
height: '0.5rem',
|
||||
left: 0,
|
||||
position: 'absolute',
|
||||
transform: 'translate(0, 100%) skewX(-45deg)',
|
||||
transformOrigin: 'top left',
|
||||
width: '100%',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -53,6 +53,7 @@
|
||||
@import './patterns/statistic';
|
||||
@import './patterns/status-light';
|
||||
@import './patterns/teardrop';
|
||||
@import './patterns/three-dimensions-card';
|
||||
@import './patterns/triangle-buttons';
|
||||
@import './patterns/video-background';
|
||||
@import './patterns/voting';
|
||||
|
46
styles/patterns/_three-dimensions-card.scss
Normal file
46
styles/patterns/_three-dimensions-card.scss
Normal file
@@ -0,0 +1,46 @@
|
||||
:root {
|
||||
--three-dimensions-card-left-side-width: 1rem;
|
||||
}
|
||||
|
||||
.three-dimensions-card {
|
||||
position: relative;
|
||||
|
||||
/* Demo */
|
||||
border: 1px solid #d1d5db;
|
||||
height: 6rem;
|
||||
width: 6rem;
|
||||
}
|
||||
|
||||
/* The left side */
|
||||
.three-dimensions-card::before {
|
||||
background: #d1d5db;
|
||||
content: '';
|
||||
|
||||
/* Position */
|
||||
top: var(--three-dimensions-card-left-side-width);
|
||||
left: 0px;
|
||||
position: absolute;
|
||||
transform: translate(-100%, 0) skewY(-45deg);
|
||||
transform-origin: left top;
|
||||
|
||||
/* Size */
|
||||
height: 100%;
|
||||
width: var(--three-dimensions-card-left-side-width);
|
||||
}
|
||||
|
||||
/* The bottom side */
|
||||
.three-dimensions-card::after {
|
||||
background: #d1d5db;
|
||||
content: '';
|
||||
|
||||
/* Position */
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
position: absolute;
|
||||
transform: translate(0, 100%) skewX(-45deg);
|
||||
transform-origin: left top;
|
||||
|
||||
/* Size */
|
||||
height: var(--three-dimensions-card-left-side-width);
|
||||
width: 100%;
|
||||
}
|
Reference in New Issue
Block a user