Welcome to my website U-GINE MEDIA. In this website I teach tutorials and share source code on some programming (HTML, CSS & JavaScript) tutorials.
Before we get started, do well to subscribe to my channel to never miss out on any update that I post every single day.
In this tutorial topic "Animated CSS Picture Motion Effects | CSS Only", we will learn how to create it following these simple easy steps.
Share this to your programmer friends. If y'all learnt something today, make sure to let me in the comments.
If interested in watching the video before running the code below, you can click the play button to get started.
Code Begins
- First, create a folder with any name you like. Then, make the necessary files inside it.
- Create a file called index.html to serve as the main file.
- Create a file called style.css for the CSS code.
- Finally, download the Images folder and put it in your project directory. This folder contains default showcase images for the website. You can also use your own images.
To start, add the following HTML codes to your index.html file. These codes include essential HTML markup with different semantic tags, such as div, form, input, button, image, etc., to build the website layout.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="index.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Effects: Motion Pictures Animation | CSS Only</title>
</head>
<body>
<div class="card">
<img src="owllet.png" class="card_front_img card_image">
<div class="card_faders">
<img class="card_fader card_image" src="owllet.png" alt="">
<img class="card_fader card_image" src="owllet.png" alt="">
<img class="card_fader card_image" src="owllet.png" alt="">
<img class="card_fader card_image" src="owllet.png" alt="">
<img class="card_fader card_image" src="owllet.png" alt="">
<img class="card_fader card_image" src="owllet.png" alt="">
<img class="card_fader card_image" src="owllet.png" alt="">
<img class="card_fader card_image" src="owllet.png" alt="">
</div>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
background: #000;
}
body {
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: #7f2e1740;
}
.card {
position: relative;
cursor: pointer;
outline: none;
transition: scale 100ms;
}
.card_front_img {
position: relative;
z-index: 2;
}
.card_image {
width: 250px;
border-radius: 0.5rem;
}
.card_faders {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 1;
transition: opacity 1500 ms;
pointer-events: none;
opacity: 0;
}
.card_fader {
position: absolute;
left: 0;
top: 0;
}
.card:hover .card_faders {
opacity: 1;
}
.card:active {
scale: 0.90;
}
.card_fader {
animation: fade-left 3s linear infinite;
}
@keyframes fade-left {
from {
scale: 1;
translate: 0%;
opacity: 1;
filter: none;
}to {
scale: 0.0;
translate: -60%;
opacity: 0;
filter: blur(10px);
}
}
.card_fader {
&:is(:nth-child(3), :nth-child(4)) {
animation-delay: 750ms;
}
&:is(:nth-child(5), :nth-child(6)) {
animation-delay: 1500ms;
}
&:is(:nth-child(7), :nth-child(8)) {
animation-delay: 2250ms;
}
}
0 Comments
We are happy to hear from you.