Simple Ken Burns effect using CSS Keyframes Animation

Simple Ken Burns effect using CSS Keyframes Animation
Simple Ken Burns Effect
Ken Burns's effect is an animation of any image by panning and zooming. It is achieved in web design with some simple CSS code. The fundamental idea of this ken burns effect was invented by a US-based documentarian named Ken burns. Nowadays, Some web designers using this technique in their web design strategy. Using this Ken Burns photo effect, we will get an excellent pan and zoom effect of the image that we will use as a background of our homepage.

Today we will create a Simple Ken Burns effect using CSS Keyframes Animation on a simple-looking homepage. Earlier I have shared a blog on Responsive Team Accordion using Bootstrap. In this tutorial of Simple Ken Burns effect using CSS Keyframes Animation, we will use Plain HTML  and CSS.



First, we will start with HTML markup. I have created a simple nav element with a div named logo and a primary menu with only five anchor tags. Then I will take another div element with "banner-img" class, where I place an image used to create our required ken burns effects. A place banner image will be dull, so I took another div element with a "banner-text" class and provided a header element, some text, and call-to-action button just like we see on a typical homepage. That's it with the HTML markup for this project.

You may also like:
We are moving on to CSS code. First, we have discarded the document default padding and margin by giving the body a margin and padding to 0. I used Lato as a font-family for the project. After that, I gave the Nav element a position fixed property and also gave it a z-index value of 1. I did this because I want nav to be top of the banner.  I have given a custom 1170px width to the nav element and tried to make it in the middle by giving it top and left value. Then I styled the logo text and placed that to the right by giving it a float left the property.

Then comes the menu, which I placed to the right by giving it float right value. Then I did some styling for the anchor tags inside the "menu" class. For the banner image, I provided a width of 100% and a height of 100vh to make full-width of the viewport. Then I have given it overflow hidden and relative position value as well.  I set an animation for the image with the name "animate" and give it a 40s animation duration and an animation timing function. I  placed the banner text element slightly left of the homepage but giving it an absolute position, top, and left value. After that, I did some basic styling for all the elements inside the banner-text class. For the CSS keyframes animation, I set the CSS like a way so that at the beginning, the image will start scaling bigger for the bottom right origin, and at 100%, the image will finish transforming form scale 1 to 1.3.

Simple Ken Burns effect using CSS (Source Code):

To create this snippet, you need to copy the HTML and CSS code and paste the code to the appropriate files and save them.

HTML:




CSS:




I hope you liked the snippet. Please feel free to leave a comment down below. I will try to answer them as soon as I can. Thanks for visiting the blog.

Please do not enter any spam link in the comment box.

Post a comment

Please do not enter any spam link in the comment box.

Post a Comment (0)

Previous Post Next Post