1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-09-09 22:00:53 +02:00

feat: Inverted corners

This commit is contained in:
Phuoc Nguyen
2022-09-19 20:43:58 +07:00
parent ba983e815a
commit 5f63d2af67
7 changed files with 94 additions and 139 deletions

View File

@@ -0,0 +1,2 @@
<div class="inverted-corners">
</div>

View File

@@ -163,6 +163,12 @@ eleventyExcludeFromCollections: true
<div class="pattern__title">Initial avatar</div>
</a>
</div>
<div class="pattern__item">
<a class="pattern__link" href="/inverted-corners/">
<div class="pattern__cover">{% include "patterns/inverted-corners.njk" %}</div>
<div class="pattern__title">Inverted corners</div>
</a>
</div>
<div class="pattern__item">
<a class="pattern__link" href="/triangle-buttons/">
<div class="pattern__cover">{% include "patterns/triangle-buttons.njk" %}</div>

View File

@@ -0,0 +1,52 @@
---
layout: layouts/post.njk
title: Inverted corners
description: Create inverted corners with CSS
keywords: css border radius, css inverted border radius, css inverted corners
---
## HTML
```html
<div class="inverted-corners">
...
</div>
```
## CSS
```css
:root {
--inverted-corners-background: #d1d5db;
--inverted-corners-size: 2rem;
}
.inverted-corners {
background-color: var(--inverted-corners-background);
/* Used to position the corner */
position: relative;
}
.inverted-corners::before {
content: '';
/* Absolute position */
bottom: calc(-2 * var(--inverted-corners-size));
left: 0;
position: absolute;
/* Size */
height: calc(2 * var(--inverted-corners-size));
width: var(--inverted-corners-size);
/* Border */
background-color: transparent;
border-top-left-radius: var(--inverted-corners-size);
box-shadow: var(--inverted-corners-background) 0px calc(-1 * var(--inverted-corners-size)) 0px 0px;
}
```
{% demo %}
{% include "patterns/inverted-corners.njk" %}
{% enddemo %}