Skip to content

Commit

Permalink
blog: raindow-text-css (#59)
Browse files Browse the repository at this point in the history
* blog: raindow-text-css

* fix packages too

* add build test

* Update index.md
  • Loading branch information
tsl143 authored Feb 12, 2024
1 parent 5769c01 commit ecaf329
Show file tree
Hide file tree
Showing 7 changed files with 14,990 additions and 17,954 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 20
- run: npm ci
- run: git config user.name "Trishul Goel" && git config user.email "[email protected]"
- run: npm run deploy
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This workflow will run tests using node and then publish to github pages

name: 🕵️‍♂️

on:
push:
branches: ['master']
pull_request:
branches: ['master']

jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 20
- run: npm ci
- run: npm run build
52 changes: 52 additions & 0 deletions content/blog/rainbow-text/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: 'Rainbow text with CSS'
date: "2024-02-11"
tags:
- css
- design
show: true
author: trishul
featuredImage: ../../assets/rainbow.png
---

Some designers can not get enough of colors and want the text not to be in solid color but rainbow colors. Traditionally developers achieve this by using a PNG image, something like this:
![Rainbow Text](./rainbow.png)

But with modern day CSS, this can be achieved with just few CSS rules.

### How
1. Create a Div
2. Add some text
3. Add some basic styling like `font-size`, `line-height` etc.
4. Add a background color `background: linear-gradient(45deg, red, orange, yellow, green, blue, indigo, violet, red);`: Rainbow 🌈
5. Add this property to the div `background-clip: text`: This makes sure the background is only used for the available text
6. Add `color: transparent`: This makes sure that the clipped background on text is completely visible.
7. That's it 😎

#### Code
```CSS
.rainbow-text {
background: linear-gradient(45deg, red, orange, yellow, green, blue, indigo, violet, red);
background-clip: text;
color: transparent;
font-size: 40px;
}
```

#### DEMO
<style>
.rainbow-text {
background: linear-gradient(45deg, red, orange, yellow, green, blue, indigo, violet, red);
background-clip: text;
color: transparent;
font-size: 60px;
font-weight: 900;
font-family: Montserrat, sans-serif;
}
</style>
<div class="rainbow-text">Trishul Goel</div>

Right click and inspect the text above and observe the CSS in inspector.

<center>Hope this helps 😊 </center>
<br/>
Binary file added content/blog/rainbow-text/rainbow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ecaf329

Please sign in to comment.