1

I need help to animate cards in bootstrap 4.

I have 4 card boxes as shown in image below, it's a simple bootstrap 4 cards deck with 4 card boxes.

cards screenshot

I am trying to slide each boxes one by one from right whenever user scroll to this section. how to achieve it?

I am not trying to make slider/carousel.

For reference check this codepen

4 boxes each needs to come from right. In the codepen above all comes at once and from left. I need it from right and one by one, when user scrolls to the section.

here is the code of boostrap 4 cards i am using

       <!-- Card Row starts here -->
   <div class="card-deck ">
      <div class="card card-detail card-text1">
         <img class="card-img-top img-fluid" src="images/Analytics.png" alt="Card image cap">
         <div class="card-body">
            <h5 class="card-title text-center">Analytics</h5>
            <p class="card-text text-center text-justify ">Our amazing tracking platform allows you to view in-depth analytics for your traffic as well as our dashboard provides proprietary reporting with actionable statistics to analyze and optimize your results in real-time. Every click gets counted.</p>
         </div>
      </div>
      <div class="card card-detail card-text1 ">
         <img class="card-img-top img-fluid" src="images/Offer-Well.png" alt="Card image cap">
         <div class="card-body">
            <h5 class="card-title text-center">Offer Well</h5>
            <p class="card-text text-center text-justify">Our OfferWall gives your users the most options to earn in one location. You can deploy a complete rewards-based monetization solution on your site in minutes as it's quite easy and simple.</p>
         </div>
      </div>
      <div class="card card-detail card-text1 ">
         <img class="card-img-top img-fluid" src="images/Inventory.png" alt="Card image cap">
         <div class="card-body">
            <h5 class="card-title text-center">Inventory</h5>
            <p class="card-text text-center text-justify ">With over 2,000 active campaigns in our system, our algorithms will find the best converting ones for your placement. Your users have the power to easily earn by watching videos, downloading apps, taking short surveys, and completing other quick offers. </p>
         </div>
      </div>
      <div class="card card-detail card-text1">
         <img class="card-img-top img-fluid" src="images/Support.png" alt="Card image cap">
         <div class="card-body">
            <h5 class="card-title text-center">Support</h5>
            <p class="card-text text-center text-justify">Each publisher is assigned a dedicated account manager that can help you with integration as well as in every aspects. Moreover, your user can contact us if they're running with issues.</p>
         </div>
      </div>
   </div>
   <!-- Card Row Ends here -->
NullPointer
  • 7,094
  • 5
  • 27
  • 41
Nimesh
  • 198
  • 1
  • 2
  • 13

2 Answers2

4

Have you tried this plugin aosjs? To animate, you just need to bind the specific elements with the valid aos attributes (refer below)

<div data-aos="fade-up"></div>

if you want to animate it once then you can add data-aos-once attribute

<div data-aos="fade-up" data-aos-once="true"></div>

and so on, check the plugin here http://michalsnik.github.io/aos/

Update: to make each of the element, shows on different duration, you can add data-aos-delay

<div id="animate1" data-aos="fade-up" data-aos-once="true" data-aos-delay="500"></div>
<div id="animate2" data-aos="fade-up" data-aos-once="true" data-aos-delay="1000"></div>
<div id="animate3" data-aos="fade-up" data-aos-once="true" data-aos-delay="1500"></div>

as seen from above sample, each element has 500ms delay.

Note: make sure you initialize the plugin first

<script>
    AOS.init();
</script>
Juliver Galleto
  • 8,831
  • 27
  • 86
  • 164
  • I am not able to make it work, it tried inlcuding it via css cdn and js cdn. But whenever i insert class in div containing card details it just disappears and no animation is shown as well. – Nimesh Jun 29 '18 at 02:35
  • have you initialize the plugin by as told on docs? – Juliver Galleto Jun 29 '18 at 02:41
  • yes i did add in header, it didn't worked either – Nimesh Jun 29 '18 at 02:45
  • have you added the aos stylesheet to the header and its script to the bottom before

    followed by plugin initialization ? and then bind the element with valid data-aos attributes as told from the developer docs?

    – Juliver Galleto Jun 29 '18 at 02:49
  • it worked, i added the classes but i am not able to achieve it one box at a time and then next, all boxes are coming at once. Please guide me here – Nimesh Jun 29 '18 at 02:58
  • 1
    you can add data-aos-delay for each element so they don't come all at once. – Juliver Galleto Jun 29 '18 at 03:25
  • Don't forget to accept my answer if it helps you :) – Juliver Galleto Jun 29 '18 at 03:31
  • @JuliverGalleto-Thanks for your effort on this question. +1.Hope this will help for Nimesh and others. – NullPointer Jun 29 '18 at 03:40
  • @JuliverGalleto can you please help js number counter effect while scroll to the section. The mechanism is there are couple of boxes with static numbers. whenever user scrolls to that section number should start increasing from 1 to the static number in box. – Nimesh Jun 29 '18 at 05:07
  • @Nimesh that would fall unto another category, can you create a post and I will just answer there :) – Juliver Galleto Jun 29 '18 at 05:52
  • @JuliverGalleto Okay i solved it though, Only issue i am facing now is it breaks the width, overflow is seen after i apply this js library http://free.nepromedia.com/enligne/index.html# Please check by scrolling left and right – Nimesh Jun 29 '18 at 07:07
  • @JuliverGalleto display:table to which element ? – Nimesh Jun 29 '18 at 07:31
  • try this to the parent wrapper, position: relative; overflow: hidden; – Juliver Galleto Jun 29 '18 at 08:00
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/174012/discussion-between-nimesh-and-juliver-galleto). – Nimesh Jun 29 '18 at 08:33
  • @JuliverGalleto i tried it didn't worked can you please check here free.nepromedia.com/enligne/index.html – Nimesh Jun 29 '18 at 09:07
2

Edited- After changes in question details

As suggested by @Juliver Galleto you can use plugin aosjs

https://github.com/michalsnik/aos

Below is my running code snippet

AOS.init({
  duration: 1200,
})
* {
  box-sizing: border-box;
}

.item {
  width: 100px;
  height: 200px;
  margin: 50px auto;
  padding-top: 75px;
  background: #ccc;
  text-align: center;
  color: #FFF;
  font-size: 3em;
}
   

 <!DOCTYPE html>
    <html lang="en" >

    <head>
      <meta charset="UTF-8">
      <title>AOS - animations</title>
      
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">

      <link rel='stylesheet prefetch' href='https://unpkg.com/aos@2.3.0/dist/aos.css'>

          <link rel="stylesheet" href="css/style.css">

      
    </head>

    <body>


    <div style="width=1200px;">
    <div style="float:left;" data-aos-delay="100" class="item" data-aos="fade-left">1</div>
    <div  style="float:left;" data-aos-delay="1600" class="item" data-aos="fade-left">2</div>
    <div  style="float:left;" data-aos-delay="2800" class="item" data-aos="fade-left">3</div>
    </div>
      <script src='https://unpkg.com/aos@2.3.0/dist/aos.js'></script>

</body>

</html>

Old Post

This feature is available in bootstrap as carousel

Sample:https://www.w3schools.com/bootstrap4/tryit.asp?filename=trybs_carousel

About carousel : https://getbootstrap.com/docs/4.0/components/carousel/

NullPointer
  • 7,094
  • 5
  • 27
  • 41
  • I am not trying to make a slider, i am just trying to animate it when user comes to that section the box 1 appears first from right opacity 0 to 1 and similarly all boxes – Nimesh Jun 29 '18 at 01:55
  • @Nimesh- updated my Answer based on your updated question – NullPointer Jun 29 '18 at 03:39
  • can you please help js number counter effect while scroll to the section. The mechanism is there are couple of boxes with static numbers. whenever user scrolls to that section number should start increasing from 1 to the static number in box. – Nimesh Jun 29 '18 at 05:23
  • issue i am facing now is it breaks the width, overflow is seen after i apply this js library https://free.nepromedia.com/enligne/index.html# Please check by scrolling left and right. – Nimesh Jun 29 '18 at 09:08