Skip to content

Commit 0e0f1a6

Browse files
committed
Add Create A Pulsing Background With CSS Animation as a css til
1 parent 72a7dfd commit 0e0f1a6

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and pairing with smart people at Hashrocket.
99

1010
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
1111

12-
_877 TILs and counting..._
12+
_878 TILs and counting..._
1313

1414
---
1515

@@ -97,6 +97,7 @@ _877 TILs and counting..._
9797
- [Apply Multiple Box Shadows To Single Element](css/apply-multiple-box-shadows-to-single-element.md)
9898
- [Apply Styles To The Last Child Of A Specific Type](css/apply-styles-to-the-last-child-of-a-specific-type.md)
9999
- [Circular Icons With A Massive Border Radius](css/circular-icons-with-a-massive-border-radius.md)
100+
- [Create A Pulsing Background With CSS Animation](css/create-a-pulsing-background-with-css-animation.md)
100101
- [Dry Up SCSS With Mixins](css/dry-up-scss-with-mixins.md)
101102
- [Lighten And Darken With CSS Brightness Filter](css/lighten-and-darken-with-css-brightness-filter.md)
102103
- [Lighten And Darken With SCSS](css/lighten-and-darken-with-scss.md)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Create A Pulsing Background With CSS Animation
2+
3+
You can create a smoothly pulsing background effect with CSS animations. This
4+
can be achieved by defining a set of keyframes that start at one background
5+
color, transitions to another color, and then transitions back to the original
6+
color.
7+
8+
```css
9+
@keyframes pulse {
10+
0%, 100% {
11+
background-color: #f56a3f;
12+
}
13+
50% {
14+
background-color: #9e42b0;
15+
}
16+
}
17+
```
18+
19+
At the beginning (`0%`) and end (`100%`) we declare the background color to be
20+
`#f56a3f`. Halfway through (`50%`) it should be `#9e42b0`. The browser will
21+
animate everything in between.
22+
23+
This can then be applied infinitely with a lengthy duration to give it a real
24+
smooth feel.
25+
26+
```css
27+
body {
28+
animation: pulse 20s infinite;
29+
}
30+
```
31+
32+
Here is a [live example](https://codepen.io/jbranchaud/pen/vYYqQjO).
33+
34+
[source](https://css-tricks.com/almanac/properties/a/animation/)

0 commit comments

Comments
 (0)