mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-31 01:29:53 +02:00
feat: Update contents
This commit is contained in:
120
contents/corner-ribbon.mdx
Normal file
120
contents/corner-ribbon.mdx
Normal file
@@ -0,0 +1,120 @@
|
||||
---
|
||||
category: Display
|
||||
created: '2019-12-01'
|
||||
description: Create a corner ribbon with CSS flexbox
|
||||
keywords: css flexbox, css ribbon
|
||||
thumbnail: /assets/css-layout/thumbnails/corner-ribbon.png
|
||||
title: Corner ribbon
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="corner-ribbon">
|
||||
<!-- The container -->
|
||||
<div class="corner-ribbon__inner">
|
||||
<!-- The ribbon -->
|
||||
<div class="corner-ribbon__ribbon"></div>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.corner-ribbon {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.corner-ribbon__inner {
|
||||
/* Displayed at the top left corner */
|
||||
left: 0px;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
|
||||
/* Size */
|
||||
height: 4rem;
|
||||
width: 4rem;
|
||||
|
||||
/* Hide the part of its children which is displayed outside */
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.corner-ribbon__ribbon {
|
||||
/* Position */
|
||||
left: 1rem;
|
||||
position: absolute;
|
||||
top: 1rem;
|
||||
|
||||
/* Size */
|
||||
height: 1.5rem;
|
||||
width: 5.656rem;
|
||||
|
||||
/* Displayed diagonally */
|
||||
transform: translate(-38px, -8px) rotate(-45deg);
|
||||
|
||||
/* Background color */
|
||||
background-color: #d1d5db;
|
||||
|
||||
/* Centerize the text content */
|
||||
text-align: center;
|
||||
}
|
||||
```
|
||||
|
||||
<Playground>
|
||||
```css styles.css hidden
|
||||
body {
|
||||
height: 24rem;
|
||||
}
|
||||
.corner-ribbon {
|
||||
position: relative;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 0.25rem;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.corner-ribbon__inner {
|
||||
/* Displayed at the top left corner */
|
||||
left: 0px;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
|
||||
/* Size */
|
||||
height: 4rem;
|
||||
width: 4rem;
|
||||
|
||||
/* Hide the part of its children which is displayed outside */
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.corner-ribbon__ribbon {
|
||||
/* Position */
|
||||
left: 1rem;
|
||||
position: absolute;
|
||||
top: 1rem;
|
||||
|
||||
/* Size */
|
||||
height: 1.5rem;
|
||||
width: 5.656rem;
|
||||
|
||||
/* Displayed diagonally */
|
||||
transform: translate(-38px, -8px) rotate(-45deg);
|
||||
|
||||
/* Background color */
|
||||
background-color: #d1d5db;
|
||||
|
||||
/* Centerize the text content */
|
||||
text-align: center;
|
||||
}
|
||||
```
|
||||
|
||||
```html index.html hidden
|
||||
<div class="corner-ribbon">
|
||||
<div class="corner-ribbon__inner">
|
||||
<div class="corner-ribbon__ribbon">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
</Playground>
|
Reference in New Issue
Block a user