class: middle center # ~ Animating css ~ --- class: middle ## Revisiting interactive elements Using the example from last week, we can demonstrate the `transition` property. ```html
```
--- class: middle center ## [list properties that can be animated with transition](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties) --- class: middle ## The `all` catchall You can also use `all` to animate any available property that changes: ```html
Test Link
```
Test Link
--- class: middle ## Creating animations with `@keyframe` Along with interactive animations with `transition`, css has another way to create animations with `@keyframes`. ```html
hiii
```
hiii
--- class: middle The states of the animation can be made more granular than `from/to` by using percentages from 0% - 100% ```html
hiii
hello
```
hiii
hello
--- class: middle ## Changing the position, scale and rotation with `transform` --- class: middle CSS `transform`s are a powerful way to change an element in 2d and 3d space. We can use `transform` instead of position absolute to move the previous example: ```html
hiii
hello
```
hiii
hello
--- class: middle We can also add rotations to the previous example: But note that we're using a block element, which will be with width of the container... ```html
hiii
```
hiii
--- class: middle Setting the width of our container to be the width of content `width: max-content;` This results in our element being centered on just the text itself: ```html
hiii
```
hiii
--- class: middle The `scale` property is also an interesting way to manipulate elements ```html
hiii
```
hiii
--- class: middle For certain `transform` effects, the order of the properties makes a difference: ```css 50% { transform: scale(0.3, 0.3) translateX(10rem) rotateZ(180deg); } ```
hiii
```css 50% { transform: translateX(10rem) rotateZ(180deg) scale(0.3, 0.3); } ```
hiii
--- class: middle `Transform` can also be used to create interactive changes, using our first example... ```html
```
--- class: middle ## Quick recap on `pseudo-class` Recall that `pseudo-classes` are those selectors that we used like `:hover` that modify an element.. in the case of hover adding styles on mouse interaction. Another type of `pseudo-class` are selectors, like `:nth-child`, `:last-child`, `:first-child` etc.. --- class: middle These `pseudo-class` selectors can be useful for selecting items within a list or group of elements: ```html
pg1
pg2
pg2
```
pg1
pg2
pg2
--- class: middle center ### keyframes demo