Header Ads Widget

Ticker

10/recent/ticker-posts

How to create vertical card sliding animation using only html and css in blogger

Get this complete guide on how to create vertical card slidding animation.  A detailed step-by-step explanation of the code I provided earlier for creating a vertical card sliding animation using only HTML and CSS.

First, let's take a look at the HTML code:


<div class="container">
<div class="card">
<h1>Card 1</h1>
</div>
<div class="card">
<h1>Card 2</h1>
</div>
<div class="card">
<h1>Card 3</h1>
</div>
</div>
We start with a container div, which will contain our cards. Inside the container div, we have three card divs. Each card div contains an h1 heading element that displays the card number.
Now let's look at the CSS code:



.container {
width: 300px;
height: 400px;
overflow: hidden;
}
.card {
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
transform: translateY(100%);
transition: transform 0.5s ease-in-out;
}
.card:first-child {
transform: translateY(0);
}
.container:hover .card:first-child {
transform: translateY(-100%);
}
We start by styling the container div. We set its width and height to 300px and 400px, respectively, and set its overflow property to hidden. This will ensure that any content that exceeds the size of the container will be hidden from view.
Next, we style the card divs. We set their height and width to 100%, and position them absolutely with top and left set to 0. This will stack the card divs on top of each other within the container div. We then set the transform property of each card div to translateY(100%). This will move the cards off the bottom of the screen, making them initially hidden from view.
We also add a transition property with a duration of 0.5 seconds and an ease-in-out timing function. This will make the sliding animation smooth and give it a nice effect.
We then target the first child card div with the :first-child pseudo-class and set its transform property to translateY(0). This will ensure that the first card is visible when the page loads, while the other cards remain hidden off the bottom of the screen.
Finally, we add a hover selector to the container div, and target the first child card div with the .card:first-child selector to set its transform property to translateY(-100%). This will slide the first card up and reveal the next card. This effect will continue as long as the user hovers over the container div.
In summary, the code creates a sliding card effect by positioning the cards absolutely within a container div, and using the transform property to move them off the bottom of the screen. The animation is triggered by a hover selector on the container div, which moves the first child card div up and reveals the next card. The transition property makes the animation smooth and visually appealing.

How to put it in blogger. 

To add the vertical card sliding animation to your Blogger blog, follow these steps:

  1. Log in to your Blogger account and go to the "Layout" section.
  2. Click on "Add a Gadget" in the sidebar where you want to add the animation.
  3. Choose "HTML/JavaScript" from the list of available gadgets.
  4. In the "Content" field, paste the HTML and CSS code for the animation.
  5. Give the gadget a title if you want, and click "Save".
  6. Once you have added the gadget to your blog, you should be able to see the vertical card sliding animation in action.
Note: If you want to customize the animation further, you can modify the HTML and CSS code to suit your needs. You can also adjust the width and height of the container div and the cards, as well as the number of cards, by changing the relevant values in the code