how to create a cubic video animation using html and css
Cubic Video Animation |html & css|
note: SOURCE CODE & THE OUTPUT WILL BE GIVEN AT THE END OF THE ARTICLE.
Cubic Video Animation |
Hello guys.I have been here today with another dynamic article about creating UI designed CUBIC VIDEO ANIMATION using Html and Css. It's really simple by following this tutorial.
Here these are the steps to get the correct result .plz follow the steps one by one
Step 1- first of all write the basic code of html
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
Step 2 - we have to write the html code for creating cubic video animation
<section id="main">
<video src="C:\Users\MADASRI\Downloads/fff.mp4" muted="" controls autoplay="" loop=""></video>
<div class="cube">
<div>
<header><video src="C:\Users\MADASRI\Downloads/fff.mp4" autoplay="" muted="" loop=""></video></header>
<header><video src="C:\Users\MADASRI\Downloads/fff.mp4" autoplay="" muted="" loop=""></video></header>
<header><video src="C:\Users\MADASRI\Downloads/fff.mp4" autoplay="" muted="" loop=""></video></header>
</div>
</div>
</section>
note: In the video tag controls attribute sholud not be contained ,And in the presence of controls we have to include "muted" and "autoplay" "loop" properties.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
Now its time to edit the section and divisions of the html codeHere im taking the section's height to be 100vh and width to be 100% and the position of the section will be relative
section {
width: 100%;
height: 100vh;
position: relative;
}
And going to the cube division im taking the the height of the cube as 400px and width is also the same.consider that the transformation style of the cube will br preserved d and the position should be absolute.here the main thing is to align the cube at the center ,so for that we have to adjust alignment using the "top" and "left" properties as shown.
section .cube {
width: 400px;
height: 400px;
top: calc(50% - 200px);
left: calc(50% - 200px);
position: absolute;
transform-style: preserve-3d;
}
Now we have to write the code for making the sides of the cube to rotate and we making all this because the cube phases should be align just like a cube.
section .cube div {
top: 0;
left: 0;
position: absolute;
width: 100%;
height: 100%;
transform-style: preserve-3d;
transform: rotateX(-20deg) rotateY(25deg) translate3d(-75px, -50px, 150px);
}
Here i have used the transform property in that i have used rotateX and rotateY values to align the sides as a cube.Step 4 - Now we have to create the cube with a video embed in it.
So for that consider the header tag and edit the css. Here took the position ,height and width to be as same in above and the main ones to change is that we have to add background color and a border to the side of the cube.And we have to include that the display property should be block for the side of the cube.
section .cube div header {
width: 100%;
height: 100%;
top: 0;
left: 0;
display: block;
border: 1px solid rgba(0, 0, 0, .1);
background: #ccc;
position: absolute;
}
Now we have to go to the STEP 2 .Here include the videos path in header tag in which the vedio tag should be lie inside the header tag like this shown below.
<header><video src="C:\Users\MADASRI\Downloads/fff.mp4" autoplay="" muted="" loop=""></video></header>
After giving the video source in the header tag .The output will be more clumsy and mess.so for that we have to make it beautiful...lets go fo it.here im taking the "section .cube div header video" tag in css and making the video to be fit to the cube faces.so for that we have to include the object fit property as shown below.
section .cube div header video {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
object-fit: cover;
filter: blur(0px);
}
Step 5 - we have to align the sides of the cube by using angles.So for that we have to consider the ":nth childs " of the header tags and have to align the angles with writing deg to them.For more clearence we will go depth in this 5th step with sub steps.
section .cube div header:nth-child(1) {
transform: rotatex(0deg) translate3d(0, 0, 200px);
}
section .cube div header:nth-child(2) {
transform: rotateY(90deg) translate3d(0, 0, -200px);
}
section .cube div header:nth-child(3) {
transform: rotatex(90deg) translate3d(0, 0, 200px);
}
Now the cube was finished , section .cube div header:nth-child(2) video {
transform: rotateY(180deg);
}
Now the video is playing with the cube.But have some problem with that is , a blur effect on backgroud is missing .Lets add it by using filter property with a value of 20px and remember that "object fit" property will be "cover" .
section video {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
object-fit: cover;
filter: blur(20px);
}
The output will be looks like this:
Download the source Code here:
If you are interested in learning more about technology and coding and ethical hacking tips and tricks ,join in our official whatsapp group with this link provided below.
click here to join in our whatsapp group.
this article was inspired and learned at online tutorials YT
No comments: