Background
Break News
How to add local font to Tailwind Css and NextJS? - Tutorial Design Pattern? - Blockchain Technology, How to create own Bitcoin virtual currency - Zustand mordern management state - Design Pattern - Flyweight Pattern? - Docker Full training Topic

[Tutorial] Image Slider Transition Effects - using javascript and CSS

Thursday 9 July 2015
|
Read: Completed in minutes

[Tutorial] Image Slider Transition Effects - using javascript and CSS

Image slider transition effects is one technical skill in website when you want to show your product to customers. See below site (image and video)

"Image Slider Transition Effects" using javascript and CSS - Webzone Tech Tips Zidane



File structures

These are my folder and files location in my PC

"Image Slider Transition Effects" using javascript and CSS - Webzone Tech Tips Zidane

Javascript - commons.js 

This file will be control image slider transition effects. I have commen in below code, please take a look. This action at 5 seconce will be auto transition to another image.


$(document).ready(function() {

 // Set Default State of each portfolio piece
 $(".sd-paging_btrix").show();
 $(".sd-paging_btrix a:first").addClass("active");

 // Get size of images, how many there are, 
 //   then determin the size of the image reel.
 var imageWidth = $(".sd-window").width();
 var imageSum = $(".sd-image_reel img").size();
 var imageReelWidth = imageWidth * imageSum;

 // Adjust the image reel to its new size
 $(".sd-image_reel").css({'width' : imageReelWidth});

 // sd-paging_btrix + Slider Function
 rotate = function(){ 
     // Get number of times to slide
     var triggerID = $active.attr("rel") - 1;    
     var image_reelPosition = triggerID * imageWidth; 

            // Remove all active class
     $(".sd-paging_btrix a").removeClass('active');  
            // Add active class (the $active is declared 
                          // in the rotateSwitch function)
     $active.addClass('active'); 

     // Slider Animation
     $(".sd-image_reel").animate({left: -image_reelPosition}, 500 );
 }; 

 //Rotation + Timing Event
 rotateSwitch = function(){ 
 
      // This will repeat itself every 5 seconds (milliseconds)
      play = setInterval(function(){    
                 $active = $('.sd-paging_btrix a.active').next();
   
          // If sd-paging_btrix reaches the end go back to first
          if ( $active.length === 0) {   
      $active = $('.sd-paging_btrix a:first'); 
          }
              rotate();    //Trigger the sd-paging_btrix and slider function
     }, 5000);   
 };

 rotateSwitch();   // Run function on launch

 // when hover to image
 $(".sd-image_reel a").hover(function()  {
         clearInterval(play); // Stop the rotation
    }, function() {
       rotateSwitch();  // Resume rotation
    }); 

 //On Click
 $(".sd-paging_btrix a").click(function() { 
 
    // Activate the clicked sd-paging_btrix
    $active = $(this);   
  
    // Reset Timer, Stop the rotation
    clearInterval(play); 
  
    // Trigger rotation immediately
    rotate();     
  
    // Resume rotation
    rotateSwitch(); 

    // Prevent browser jump to link anchor  
    return false;   
 }); 

});

CSS - style.css

This file will control style of website, so easy to use it, please take a look.




.sd-container {
 width: 660px;padding: 0;margin: 0 auto;
}

.sd-image_reel {
 position: absolute;top: 0; left: 0;
}

.sd-image_reel img {float: left;}

.sd-main-view {float: left;position: relative;}

.sd-window {
     -moz-box-shadow: 0px 0px 5px #303030;
     -webkit-box-shadow: 0px 0px 5px #303030;
     box-shadow: 0px 0px 5px #303030;
     border:1px solid #000000;
     height:240px; 
     width: 660px;
     margin-top:15px;overflow: hidden;
     position: relative;
}

.sd-paging_btrix {
     position: absolute;
     bottom: 10px; right: -7px;
     width: 178px; height:47px;
     z-index: 100; /*--Assures the paging stays on the top layer--*/
     text-align: center;
     line-height: 40px;
     background: url(../paging_bg2.png) no-repeat;
     display: none; 
}

.sd-paging_btrix a {
      padding: 5px;text-decoration: none;color: #fff;
}

.sd-paging_btrix a.active {
     font-weight: bold; background: #920000; border: 1px solid #610000;
     -moz-border-radius: 3px;
     -khtml-border-radius: 3px;
     -webkit-border-radius: 3px;
}

.sd-paging_btrix a:hover {font-weight: bold;}




index.html - main site

This file will show to you the GUI same here. I have three button here so i must have three <a> section with 3 image (1.jpg, 2.png, 3,jpg) ...


  <a href="https://learn-tech-tips.blogspot.com/">
               <img alt="Learn Tech Tips" src="1.jpg" width="660" /></a>


<html lang="en">
<head>
  
  <title>Learn Tech Tips:</title>
    
  <link href="css/styles.css" rel="stylesheet"></link>   
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" 
             type="text/javascript"></script>
  <script src="commons.js" type="text/javascript"></script>   
</head>

<body>  

  <div class="sd-container">
    <div class="sd-main-view">
      <div class="sd-window">
        <div class="sd-image_reel">
           <a href="https://learn-tech-tips.blogspot.com/">
               <img alt="Learn Tech Tips" src="1.jpg" width="660" /></a>
           <a href="https://learn-tech-tips.blogspot.com/">
               <img alt="Learn Tech Tips" src="2.png" width="660" /></a>
           <a href="https://learn-tech-tips.blogspot.com/">
               <img alt="Learn Tech Tips" src="3.jpg" width="660" /></a>

        </div>
     </div>
     <div class="sd-paging_btrix">
         <a href="https://www.blogger.com/blogger.g?blogID=1486059340628392194#" 
              rel="1">1</a>
         <a href="https://www.blogger.com/blogger.g?blogID=1486059340628392194#" 
              rel="2">2</a>
         <a href="https://www.blogger.com/blogger.g?blogID=1486059340628392194#" 
              rel="3">3</a>
      </div>
   </div>
 </div>
</body>
</html>





Are you interested in topic Image Slider Transition Effects - using javascript and CSS from Webzone Tech Tips? If you have any thoughts or questions, please share them in the comment section below. I would love to hear from you and chat about it

Webzone Tech Tips Zidane


🙇🏼 Your Feedback Is Valuable and Helpful to Us - Webzone - all things Tech Tips web development Zidane 🙇🏼
Popular Webzone Tech Tips topic maybe you will be like it - by Webzone Tech Tips - Zidane
As a student, I found Blogspot very useful when I joined in 2014. I have been a developer for years . To give back and share what I learned, I started Webzone, a blog with tech tips. You can also search for tech tips zidane on Google and find my helpful posts. Love you all,

I am glad you visited my blog. I hope you find it useful for learning tech tips and webzone tricks. If you have any technical issues, feel free to browse my posts and see if they can help you solve them. You can also leave a comment or contact me if you need more assistance. Here is my blog address: https://learn-tech-tips.blogspot.com.

My blog where I share my passion for web development, webzone design, and tech tips. You will find tutorials on how to build websites from scratch, using hot trends frameworks like nestjs, nextjs, cakephp, devops, docker, and more. You will also learn how to fix common bugs on development, like a mini stackoverflow. Plus, you will discover how to easily learn programming languages such as PHP (CAKEPHP, LARAVEL), C#, C++, Web(HTML, CSS, javascript), and other useful things like Office (Excel, Photoshop). I hope you enjoy my blog and find it helpful for your projects. :)

Thanks and Best Regards!
Follow me on Tiktok @learntechtips and send me a direct message. I will be happy to chat with you.
Webzone - Zidane (huuvi168@gmail.com)
I'm developer, I like code, I like to learn new technology and want to be friend with people for learn each other
I'm a developer who loves coding, learning new technologies, and making friends with people who share the same passion. I have been a full stack developer since 2015, with more than years of experience in web development.
Copyright @2022(November) Version 1.0.0 - By Webzone, all things Tech Tips for Web Development Zidane
https://learn-tech-tips.blogspot.com