Advertisement
1xptolevitico69

HTML slider onclick (no frameworks) (no javascript) pure CSS

Jan 1st, 2022
1,642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.53 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>HTML slider onclick (no frameworks) (no javascript) pure CSS</title>
  8. <style>
  9.  
  10. a {
  11.   display: block;
  12.   font-size: 20px;
  13.   font-family: verdana;
  14.   width: 150px;
  15.   border: none;
  16.   outline: none;
  17.   color: white;
  18.   background-color: red;
  19.   text-decoration: none;
  20.   text-align: center;
  21.   padding: 5px 10px;
  22.   position: absolute;
  23.   z-index: 1;
  24.   top: 10px;
  25.   right: 10px;
  26. }
  27.  
  28. .stop {
  29.   display: block;
  30.   font-size: 20px;
  31.   font-family: verdana;
  32.   width: 150px;
  33.   border: none;
  34.   outline: none;
  35.   color: white;
  36.   background-color: red;
  37.   text-decoration: none;
  38.   text-align: center;
  39.   padding: 5px 10px;
  40.   position: absolute;
  41.   z-index: 1;
  42.   top: 100px;
  43.   right: 10px;
  44. }
  45.  
  46. slider_container {
  47.   margin: auto;
  48.   position: relative;
  49.   width: 700px;
  50.   height: 400px;
  51.   border: 5px solid red;
  52.   display: block;
  53.   overflow-x: hidden;
  54.   overflow-y: hidden;
  55.   box-sizing: border-box;
  56. }
  57. slider {
  58.   position: absolute;
  59.   width: 3500px;
  60.   top: 0;
  61.   left: 0;
  62. }
  63. img {
  64.   width: 700px;
  65.   height: 400px;
  66.   float: left;
  67. }
  68. #slider:target {
  69.   animation: move 10s linear infinite;
  70. }
  71.  
  72. .clone{
  73. position:absolute;
  74. top:10px;
  75. left:10px;
  76. text-decoration: none;
  77. background-color: red;
  78. width: 150px;
  79. text-align: center;
  80. color: snow;
  81. font-family: arial black;
  82. padding: 5px 20px;
  83. }
  84.  
  85.  
  86.  
  87. @keyframes move {
  88.   0% {
  89.     margin-left: -700px;
  90.   }
  91.   14% {
  92.     margin-left: -700px;
  93.   }
  94.   24% {
  95.     margin-left: -700px;
  96.   }
  97.   38% {
  98.     margin-left: -1400px;
  99.   }
  100.   48% {
  101.     margin-left: -1400px;
  102.   }
  103.   62% {
  104.     margin-left: -2100px;
  105.   }
  106.   72% {
  107.     margin-left: -2100px;
  108.   }
  109.   86% {
  110.     margin-left: -2800px;
  111.   }
  112.   100% {
  113.     margin-left: -2800px;
  114.   }
  115. }
  116.  
  117.  
  118. </style>
  119. </head>
  120. <body>
  121.  
  122. <a href='#slider' class='start'>Start Slider Animation</a>
  123.  
  124. <a href='#' class='stop'>Stop Slider Animation</a>
  125.  
  126. <slider_container>
  127.   <slider id='slider'>
  128.     <img src='https://1xpto.netlify.app/pics/1.jpg'>
  129.     <img src='https://1xpto.netlify.app/pics/1.jpg'>
  130.     <img src='https://1xpto.netlify.app/pics/3.jpg'>
  131.     <img src='https://1xpto.netlify.app/pics/4.jpg'>
  132.     <img src='https://1xpto.netlify.app/pics/7.jpg'>
  133.   </slider>
  134. </slider_container>
  135.  
  136. <a class='clone' href='https://www.youtube.com/channel/UCqLpDK0eOsG1eEeF9jOUZkw'>SUBSCRIBE</a>
  137.  
  138.   <script></script>
  139. </body>
  140. </html>
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement