Skip to content
Youths Forum Youths Forum Youths Forum

Tech Blogs & Programming Tutorials

Youths Forum Youths Forum Youths Forum

Tech Blogs & Programming Tutorials

  • Blog
  • News
  • Programming
    • PHP
    • JavaScript
    • JQuery
    • CSS
    • HTML
    • API
  • Stock Market Live
  • Automobiles
    • Cars
  • Gadgets
    • Phones
    • Android Phones

Categories

  • Automobiles (12)
    • Cars (7)
  • Blog (103)
    • Poems (2)
    • Space (2)
  • Command (2)
  • Education (2)
  • Entertainment (4)
  • Gadgets (9)
    • Phones (8)
      • Android Phones (4)
  • HTML Templates (11)
  • IT Training Institutes (1)
  • Lifestyle (4)
  • News (51)
  • Others (23)
  • Programming (296)
    • API (16)
    • CSS (83)
    • Database (4)
    • Hosting (1)
    • HTML (37)
    • JavaScript (117)
      • JQuery (27)
      • ReactJS (7)
    • PHP (116)
  • Python (3)
  • recipes (1)
  • SEE Result (1)
  • Server (3)
  • Blog
  • News
  • Programming
    • PHP
    • JavaScript
    • JQuery
    • CSS
    • HTML
    • API
  • Stock Market Live
  • Automobiles
    • Cars
  • Gadgets
    • Phones
    • Android Phones
Close

Search

JQuery

Animated Card Slider using jQuery

By Admin
January 27, 2021 2 Min Read
0

In this article, we are going to design an animated card slider with next/previous button using jQuery.

The following source code provides us with a card slider UI design with next and previous button. The basic idea is to allow users to swipe through multiple number of cards that may include image, title and excerpt text.

 

Full Source Code :

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" ></script>

<style type="text/css">
  .disabled{
    color:#aaa;
  }
  body{
    background: #f4f4f4;
  }
  .sans{
    font-family: sans-serif;
  }
  .box-wrapper{
    display: none;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
  }
  .box{
    background: #fff;
    position: absolute;
    width:600px;
    height:600px; 
    border: 1px solid rgba(0,0,0,0.1);
  }

  .nav-wrapper .fa{
    cursor: pointer;
    font-weight: 600;
    font-size: 22px;
    margin-left: 20px;
  }
  .nav-wrapper{
    float: right;
    padding: 16px 20px;
    text-align: right;
    display: inline-block;
  }
  .head-wrapper{
    font-weight: bold;
    letter-spacing: 1.3;
    font-size: 20px;
    display: inline-block;
    float: left;
  }
  .image-wrapper{
    padding-bottom: 0px!important;
  }
  .image-wrapper img{
    width: 100%;
  }
  .content{
    padding-top: 0px!important;
  }
  .content h4{
    margin-bottom:0px;
    font-size: 26px;
  }
  .content a{
    text-decoration: none;
  }
  .content p{
      font-size: 19px;
      line-height: 22px;
      color:#777;
      margin-top:6px;
  }
  .pad{
    padding: 16px 20px;
  }
  .remove-box{
    transition-duration: 1s;
    transform: rotatey(-90deg);
  }
  .show-box{
    transition-duration: 1s;
    transform: rotatey(0deg);
  }
</style>

<?php
  $data = array(
    array(
      'title'=>'Zoom Meeting : Is it really safe and deserves to be used?',
      'image'=>'https://reeteshghimire.com.np/wp-content/uploads/2020/06/zoom-video-calling.jpg',
      'description'=>'Coronavirus (Covid-19) pandemic has changed our lives drastically as every one of us is in our home quarantine',
      'link'=>'https://reeteshghimire.com.np/2020/06/27/zoom-meeting-is-it-really-safe-and-deserves-to-be-used/'
    ),
    array(
      'title'=>'Everything you need to know about Sagoon',
      'image'=>'https://reeteshghimire.com.np/wp-content/uploads/2020/06/everything-you-need-to-know-about-sagoon.jpg',
      'description'=>'Sagoon is an early stage social commerce platform where people across the world get connected, share their things and also earn money from it',
      'link'=>'https://reeteshghimire.com.np/2020/06/25/everything-you-need-to-know-about-sagoon/'
    ),
    array(
      'title'=>'What Does The Future Hold For Crypto-Currency ?',
      'image'=>'https://reeteshghimire.com.np/wp-content/uploads/2020/06/future-of-cryptocurrency.jpg',
      'description'=>'If you are curious to know about Crypto-currency and what the future holds for it, then keep reading the article until the end and know about it thoroughly',
      'link'=>'https://reeteshghimire.com.np/2020/06/23/what-does-the-future-hold-for-crypto-currency/'
    ),
    array(
      'title'=>'QR Code Reader using PHP Library',
      'image'=>'https://reeteshghimire.com.np/wp-content/uploads/2021/01/qr-code-reader-decoder-using-php-600x400.jpg',
      'description'=>'The recommended method of installing this library is via Composer. We need to run the following command from the project root',
      'link'=>'https://reeteshghimire.com.np/2021/01/25/qr-code-reader-using-php-library/'
    )
  );
?>

<div class="box-wrapper">
  <?php $i=count($data)+1; foreach($data as $d){ $i--;?>
    <div class="box box-<?php echo $i;?>">
      <div class="head-wrapper sans pad">
        <?php echo $i;?>/<?php echo count($data);?>
      </div>
      <div class="nav-wrapper pad">
        <i class="disabled btn-prev fa fa-angle-left" onclick="previous();"></i>
        <i class="btn-next fa fa-angle-right" onclick="next();"></i>
      </div>
      <div class="image-wrapper pad">
        <a target="_blank" href="<?php echo $d['link'];?>">
          <img src="<?php echo $d['image'];?>">
        </a>
      </div>
      <div class="content sans pad">
        <a target="_blank" href="<?php echo $d['link'];?>">
          <h4><?php echo $d['title'];?></h4>
        </a>
        <p><?php echo $d['description'];?></p>
      </div>
    </div>
  <?php } ?>
</div>

<script>
  var active_box = 1;
  var box_count = '<?php echo count($data);?>';
  setTimeout(function(){
    $(".box-wrapper").fadeIn();
    $(".box-wrapper").css('display','flex');
  },2000);
  function next(){
    if(active_box>=box_count){
      return false;
    }
    if(active_box>=box_count-1){
      $(".btn-next").addClass('disabled');
    }else{
      $(".btn-next").removeClass('disabled');
      $(".btn-prev").removeClass('disabled');
    }
    next_active_box = active_box+1;
    active_box_id = '.box-'+active_box;
    next_active_box_id = '.box-'+next_active_box;
    $(active_box_id).addClass('remove-box');
    $(next_active_box_id).addClass('show-box');
    $(active_box_id).removeClass('show-box');
    $(next_active_box_id).show();
    active_box = next_active_box;
  }

  function previous(){
    if(active_box<=1){
      return false;
    }
    if(active_box<=2){
      $(".btn-prev").addClass('disabled');
    }else{
      $(".btn-prev").removeClass('disabled');
      $(".btn-next").removeClass('disabled');
    }
    next_active_box = active_box-1;
    active_box_id = '.box-'+active_box;
    next_active_box_id = '.box-'+next_active_box;
    $(next_active_box_id).removeClass('remove-box');
    $(next_active_box_id).addClass('show-box');
    $(next_active_box_id).show();
    active_box = next_active_box;
  }
</script>

Follow this video for complete guidance :

 

Tags:

animationcardslider
Author

Admin

Follow Me
Other Articles
Previous

Design a Attractive Custom 404 Page

Next

Create Custom YouTube Playlist using PHP and JavaScript

No Comment! Be the first one.

Leave a Reply

Your email address will not be published. Required fields are marked *

FIFA World Cup 2026 Predict and Win by SportsGuff

Recent Posts

  • Unpacking Nepal’s Record Rs 2.12 Trillion Budget and What It Means for You
  • How to Write a Strong Scholarship Application: The Ultimate Step-by-Step Guide
  • How to Prepare for Exams Without Stress: The Ultimate Science-Backed Guide
  • Chiranjibi Adhikari Appointed Acting President of CAN Federation
  • How to Design a Student Marksheet Using HTML and CSS

Tags

adsense ai animate animation animation using HTML and CSS API blog calculator chatgpt Cryptocurrency CSS css animation design Email Facebook featured filemanager file manager free template google htaccess HTML image Instagram interview javascript JQuery jquery ui NADA AutoShow NADA Auto Show 2024 password PHP Progressive Web App PWA QR random react reactjs Rotate travel Twitter vpn youthforum youthsforum youtube

About Us

At Youths Forum, we are passionate about sharing knowledge that empowers students, educators, professionals, and technology enthusiasts.

Our Mission

Our mission is simple: to make technology and education accessible, understandable, and beneficial for everyone. We strive to create content that helps our readers learn new skills and stay updated with industry developments.

RSS RSS

  • Unpacking Nepal’s Record Rs 2.12 Trillion Budget and What It Means for You Admin
  • How to Write a Strong Scholarship Application: The Ultimate Step-by-Step Guide Admin
  • How to Prepare for Exams Without Stress: The Ultimate Science-Backed Guide Admin

Quick Links

  • Stock Market Live
  • Parliament Election 2082
Copyright 2026 — Youths Forum. All rights reserved. Blogsy WordPress Theme