Advertisement
1xptolevitico69

How to create a Slideshow Carousel

Aug 20th, 2022
1,298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.06 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5.   <!-- Global site tag (gtag.js) - Google Analytics -->
  6.   <script async="" src="https://www.googletagmanager.com/gtag/js?id=G-420XFJRS1M"></script>
  7.   <script>
  8.     window.dataLayer = window.dataLayer || [];
  9.  
  10.     function gtag() {
  11.       dataLayer.push(arguments);
  12.     }
  13.     gtag('js', new Date());
  14.     gtag('config', 'G-420XFJRS1M');
  15.   </script>
  16.   <link rel="shortcut icon" href="https://1xpto.netlify.app/items/favicon.gif" type="image/x-icon">
  17.   <meta charset="UTF-8">
  18.   <meta http-equiv="X-UA-Compatible" content="IE=edge">
  19.   <meta name="keywords" content="Javascript Slideshow Carousel">
  20.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  21.   <title>Javascript Slideshow Carousel</title>
  22.   <style>
  23.     #flex_box {
  24.       display: flex;
  25.       overflow-x: scroll;
  26.     }
  27.  
  28.     #image {
  29.       box-sizing: border-box;
  30.       width: 500px;
  31.       height: auto;
  32.       border: 5px solid red;
  33.       padding: 5px;
  34.       margin: 0 5px;
  35.     }
  36.  
  37.     body {
  38.       margin: 0;
  39.     }
  40.  
  41.     .header {
  42.       color: navy;
  43.       font-family: arial black;
  44.       font-size: 4vw;
  45.       text-align: center;
  46.     }
  47.  
  48.     @media all and (orientation: portrait) and (max-width: 425px) {
  49.       .header {
  50.         font-size: 8vw;
  51.       }
  52.  
  53.       #image {
  54.         width: 100%;
  55.         height: auto;
  56.         margin: 1px 0;
  57.       }
  58.  
  59.       #flex_box {
  60.         flex-direction: column;
  61.       }
  62.  
  63.       body {
  64.         overflow-y: scroll;
  65.       }
  66.     }
  67.  
  68.     @media all and (orientation: landscape) and (max-width: 640px) {
  69.       .header {
  70.         font-size: 7vw;
  71.       }
  72.  
  73.       #image {
  74.         width: 100%;
  75.         height: auto;
  76.         margin: 1px 0;
  77.       }
  78.  
  79.       #flex_box {
  80.         flex-direction: column;
  81.       }
  82.  
  83.       body {
  84.         overflow-y: scroll;
  85.       }
  86.     }
  87.   </style>
  88. </head>
  89.  
  90. <body>
  91.  
  92.   <h1 class='header'>JavaScript Carousel <br> Gif Fullscreen Onclick </h1>
  93.  
  94.   <div id='flex_box'></div>
  95.  
  96.   <script>
  97.     carousel = ['https://1xpto.netlify.app/gif/gif1.gif', 'https://1xpto.netlify.app/gif/gif2.gif', 'https://1xpto.netlify.app/gif/gif3.gif', 'https://1xpto.netlify.app/gif/gif4.gif', 'https://1xpto.netlify.app/gif/gif5.gif', 'https://1xpto.netlify.app/gif/gif6.gif', 'https://1xpto.netlify.app/gif/gif7.gif', 'https://1xpto.netlify.app/gif/gif8.gif'];
  98.     title = ['Roller coaster', 'Feeling like trash', 'Getting dizzy', 'Burn out', 'Too much caffeine', 'Fiddler joy', 'Getting sleepy', 'Studying with view'];
  99.     for (i = 0; i < carousel.length; i++) {
  100.      image = document.createElement('img');
  101.      document.body.appendChild(image);
  102.      flex_box.appendChild(image);
  103.      image.id = 'image';
  104.      image.src = carousel[i];
  105.      image.title = title[i];
  106.    }
  107.  
  108.    function fullscreen() {
  109.      img = document.getElementsByTagName("img");
  110.      for (i = 0; i < img.length; i++) {
  111.        img[i].addEventListener("click", getFull);
  112.      }
  113.  
  114.      function getFull(e) {
  115.        e.target.requestFullscreen();
  116.      }
  117.    }
  118.    fullscreen();
  119.  </script>
  120. </body>
  121.  
  122. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement