Add button animation snippets
This commit is contained in:
@ -14,7 +14,7 @@ Creates a border animation on hover.
|
|||||||
|
|
||||||
```css
|
```css
|
||||||
.animated-border-button {
|
.animated-border-button {
|
||||||
background-color: #141414;
|
background-color: #263059;
|
||||||
border: none;
|
border: none;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
outline: none;
|
outline: none;
|
||||||
@ -33,13 +33,13 @@ Creates a border animation on hover.
|
|||||||
}
|
}
|
||||||
|
|
||||||
.animated-border-button:before {
|
.animated-border-button:before {
|
||||||
border-top: 2px solid #141414;
|
border-top: 2px solid #263059;
|
||||||
right: 0;
|
right: 0;
|
||||||
top: -4px;
|
top: -4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.animated-border-button:after {
|
.animated-border-button:after {
|
||||||
border-bottom: 2px solid #141414;
|
border-bottom: 2px solid #263059;
|
||||||
bottom: -4px;
|
bottom: -4px;
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
52
snippets/button-focus-swing-animation.md
Normal file
52
snippets/button-focus-swing-animation.md
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
---
|
||||||
|
title: Button swing animation
|
||||||
|
tags: animation,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
|
Creates a swing animation on focus.
|
||||||
|
|
||||||
|
- Use an appropriate `transition` to animate changes to the element.
|
||||||
|
- Use the `:focus` pseudo-class to apply an `animation` that uses `transform` to make the element swing.
|
||||||
|
- Use `animation-iteration-count` to only play the animation once.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<button class="button-swing">Submit</button>
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
.button-swing {
|
||||||
|
color: #65b5f6;
|
||||||
|
background-color: transparent;
|
||||||
|
border: 1px solid #65b5f6;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-swing:focus {
|
||||||
|
animation: swing 1s ease;
|
||||||
|
animation-iteration-count: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes swing {
|
||||||
|
15% {
|
||||||
|
transform: translateX(5px);
|
||||||
|
}
|
||||||
|
30% {
|
||||||
|
transform: translateX(-5px);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translateX(3px);
|
||||||
|
}
|
||||||
|
65% {
|
||||||
|
transform: translateX(-3px);
|
||||||
|
}
|
||||||
|
80% {
|
||||||
|
transform: translateX(2px);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
29
snippets/button-hover-grow-animation.md
Normal file
29
snippets/button-hover-grow-animation.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
title: Button grow animation
|
||||||
|
tags: animation,beginner
|
||||||
|
---
|
||||||
|
|
||||||
|
Creates a grow animation on hover.
|
||||||
|
|
||||||
|
- Use an appropriate `transition` to animate changes to the element.
|
||||||
|
- Use the `:hover` pseudo-class to change the `transform` to `scale(1.1)`, growing the element when the user hovers over it.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<button class="button-grow">Submit</button>
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
.button-grow {
|
||||||
|
color: #65b5f6;
|
||||||
|
background-color: transparent;
|
||||||
|
border: 1px solid #65b5f6;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-grow:hover {
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
```
|
||||||
29
snippets/button-hover-shrink-animation.md
Normal file
29
snippets/button-hover-shrink-animation.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
title: Button shrink animation
|
||||||
|
tags: animation,beginner
|
||||||
|
---
|
||||||
|
|
||||||
|
Creates a shrink animation on hover.
|
||||||
|
|
||||||
|
- Use an appropriate `transition` to animate changes to the element.
|
||||||
|
- Use the `:hover` pseudo-class to change the `transform` to `scale(0.8)`, shrinking the element when the user hovers over it.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<button class="button-shrink">Submit</button>
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
.button-shrink {
|
||||||
|
color: #65b5f6;
|
||||||
|
background-color: transparent;
|
||||||
|
border: 1px solid #65b5f6;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-shrink:hover {
|
||||||
|
transform: scale(0.8);
|
||||||
|
}
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user