mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-09-02 02:12:40 +02:00
feat: Update contents
This commit is contained in:
121
contents/three-dimensions-card.mdx
Normal file
121
contents/three-dimensions-card.mdx
Normal file
@@ -0,0 +1,121 @@
|
||||
---
|
||||
category: Display
|
||||
created: '2021-04-04'
|
||||
description: Create a 3D card with CSS
|
||||
keywords: css 3D card
|
||||
thumbnail: /assets/css-layout/thumbnails/three-dimensions-card.png
|
||||
title: Three dimensions 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%;
|
||||
}
|
||||
```
|
||||
|
||||
<Playground>
|
||||
```css styles.css hidden
|
||||
:root {
|
||||
--three-dimensions-card-left-side-width: 1rem;
|
||||
}
|
||||
|
||||
body {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.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%;
|
||||
}
|
||||
```
|
||||
|
||||
```html index.html hidden
|
||||
<div class="three-dimensions-card"></div>
|
||||
```
|
||||
</Playground>
|
Reference in New Issue
Block a user