Last active
September 7, 2022 18:44
-
-
Save ThinhPhan/32c1de7c7fde8a31027a1e3d8e9e89c8 to your computer and use it in GitHub Desktop.
Css Util
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Utility CSS | |
```css | |
// Create a vertical line center | |
.vertical-line { | |
background: linear-gradient(#000, #000) no-repeat center/2px 100%; | |
} | |
``` | |
`background: linear-gradient(#000, #000) no-repeat center/2px 100%;` | |
## How this works | |
- `linear-gradient(#000, #000)` this creates a background-image so we can later use background-size to contain it. | |
- `no-repeat` this stops the gradient from repeating when we do put background-size on it. | |
- `center` - this is the background-position this is where we put the "diving line" | |
- `/2px 100%` - this is making the image 2px wide and 100% of the element you put it in. | |
## This is the extended version | |
```css | |
background-image: linear-gradient(#000, #000); | |
background-size: 2px 100%; | |
background-repeat: no-repeat; | |
background-position: center center; | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment