15. CSS Flourishes
MSER 521�Fall 2025
1
Outline
2
Outline
3
<img> tag v. CSS Background Images
There are a few ways to make images:
Demo: background-media/01-images-mixed-sizes
Background Image Properties
background-attachment: fixed; /* parallax effects */
background-size: cover;
background-repeat: no-repeat;
background-position: top center;
filter: grayscale(100%); /* list of filters here */
Object-Fit Property for Images
Historically, using background images was the only way to crop images without actually modifying the original image (via photoshop or some other image editor). Now, you can also set the CSS object-fit property to crop images. More information here: https://www.w3schools.com/css/css3_object-fit.asp
Parallax Effects
Demos
Filters
There are a lot of interesting ways to create filter:
Video Backgrounds
Examples of video backgrounds:
Demo: background-media/05-video-background
Audio Tags
Examples of video backgrounds:
Demos:
Outline
11
Pseudo-class
A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s). For example, the pseudo-class :hover can be used to select a button when a user's pointer hovers over the button and this selected button can then be styled.”
When do you use them (see demos):
Pseudo-class Demos
Demo walkthrough (transitions/01-pseudo-classes):
Outline
14
Transitions
Transitions are often used in combination with a pseudo-class to “transition” between the off state and the on state using animation.
15
Transition Syntax
16
Transition: Example
a {
color: red;
transition: all 0.3s ease-out 0s;
transition-property: color, margin;
}
a:hover {
color: blue;
font-size: 200%;
}
17
Transitions: Demo
transitions/02-pseudo-classes-with-transitions
18
Preview: Using Transitions with JavaScript
Transitions are often used in combination with JavaScript (which we’ll talk more about after Spring Break. Let’s take a look at some techniques that use transitions and JavaScript and talk through how they work…
Outline
20
Keyframe Animations
What is a keyframe?
Keyframes are a way to make more complex animations.
Example: Define the keyframe, then apply it
#myMessage {
animation: bounceIn 2s ease-in-out;
}
@keyframes bounceIn {
0% {
transform: scale(0.1);
}
60% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}
Animation properties
animation-name | Name of the keyframe you defined. |
animation-timing-function | e.g., linear, ease-in, ease-out |
animation-delay | how long to wait before animation starts |
animation-iteration-count | How many times animation should repeat |
animation-direction | normal, reverse, alternate, alternate-reverse |
animation-fill-mode | e.g., forwards, backwards, normal, both |
animation-play-state | e.g., paused, running |
Demos
Let’s check out the demo files!
Gallery of Inspiration
There are also a ton of animation libraries that you can use to jazz up your websites. For instance:
Outline
26
27