mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-04 05:07:32 +02:00
82 lines
1.4 KiB
Plaintext
82 lines
1.4 KiB
Plaintext
---
|
|
category: Display
|
|
created: '2019-12-30'
|
|
description: Create a teardrop with CSS
|
|
keywords: css border radius, css teardrop, css water drop shape, css water droplet
|
|
thumbnail: /assets/css-layout/thumbnails/teardrop.png
|
|
title: Teardrop
|
|
---
|
|
|
|
## HTML
|
|
|
|
```html index.html
|
|
<div class="teardrop">
|
|
<!-- Display the content vertically -->
|
|
<div class="teardrop__content">...</div>
|
|
</div>
|
|
```
|
|
|
|
## CSS
|
|
|
|
```css styles.css
|
|
.teardrop {
|
|
/* Center the content */
|
|
align-items: center;
|
|
display: flex;
|
|
justify-content: center;
|
|
|
|
/* Border */
|
|
border: 2px solid #d1d5db;
|
|
border-radius: 0px 50% 50% 50%;
|
|
|
|
/* Angle at the top */
|
|
transform: rotate(45deg);
|
|
|
|
/* Size */
|
|
height: 4rem;
|
|
width: 4rem;
|
|
}
|
|
|
|
.teardrop__content {
|
|
transform: rotate(-45deg);
|
|
}
|
|
```
|
|
|
|
<Playground>
|
|
```css styles.css hidden
|
|
body {
|
|
align-items: center;
|
|
display: flex;
|
|
justify-content: center;
|
|
}
|
|
|
|
.teardrop {
|
|
/* Center the content */
|
|
align-items: center;
|
|
display: flex;
|
|
justify-content: center;
|
|
|
|
/* Border */
|
|
border: 2px solid #d1d5db;
|
|
border-radius: 0px 50% 50% 50%;
|
|
|
|
/* Angle at the top */
|
|
transform: rotate(45deg);
|
|
|
|
/* Size */
|
|
height: 4rem;
|
|
width: 4rem;
|
|
}
|
|
|
|
.teardrop__content {
|
|
transform: rotate(-45deg);
|
|
}
|
|
```
|
|
|
|
```html index.html hidden
|
|
<div class="teardrop">
|
|
<div class="teardrop__content"></div>
|
|
</div>
|
|
```
|
|
</Playground>
|