create account

Automatic Slideshow HTML , CSS , JS by foxlead

View this thread on: hive.blogpeakd.comecency.com
· @foxlead ·
$3.42
Automatic Slideshow HTML , CSS , JS
Hey there Guys , how are you doing hope you are doing well , yea thanks for asking i am alos doing fine thanks 😃 , i will like to share a tutorial of mine with you today it is a slideshow using HTML , CSS , AND JS....


![onld.jpg](https://files.peakd.com/file/peakd-hive/foxlead/23xeX8drYnupRnCithHKAYN2P4ewx9jrNMr4bQK5Sd2RBbiUchEXMCzSV5rgARub3ubXW.jpg)

this slideshow will be able to loop over other images within it container but first...
A Carousle is somewhat of a roller of a particular item keeping them in loop repeating the over and over again till................................................................ well.... till ...... till...

so you gert the picture .
nopw lets start with  the code to sreate a slideshow 
here is my HTML CODE :

```
<div class="slideshow-container">

<div class="mySlides fade">
  <img src="https://wallpaperaccess.com/full/4334829.jpg" style="width:100%">
</div>

<div class="mySlides fade">
  <img src="https://wallpaperaccess.com/full/4970607.jpg" style="width:100%">
</div>

<div class="mySlides fade">
  <img src="https://wallpaperaccess.com/full/4970613.jpg" style="width:100%">
</div>

<a class="prev" onclick="slideBtn(-1)">❮</a>
<a class="next" onclick="slideBtn(1)">❯</a>


<h2> Hive Landing Page Automatic Javascript SlideShow </h2>
</div>
<br>


```

Now as you can see the slideshwo-container is the one that holds all of the contents of itself..

while the images a placed within a div element to place the as an inline-element to a block element which is the DIV tag .

the output without CSS 


![shks.jpg](https://files.peakd.com/file/peakd-hive/foxlead/23zGXuYfaKYY2PQvcW38awLMGEAZs5AbpmFo48cKwFj4YnUdXJ5vbrgc2984pvSm6NnKd.jpg)

Here is my CSS :

```
* {box-sizing: border-box ;}
body {font-family: Verdana, sans-serif; margin:0 ; color : #fff ;
background : linear-gradient(-180deg , #322f2f , black) ;}
.mySlides {display: none}
img {vertical-align: middle;}

/* Slideshow container */
.slideshow-container {
  max-width: 1000px;
  max-height : 400px;
  position: relative;
  margin: auto;
}

/* Next & previous buttons */
.prev, .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  padding: 16px;
  margin-top: -22px;
  color: white;
  font-weight: bold;
  font-size: 18px;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;
  user-select: none;
}

/* Position the "next button" to the right */
.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
  background-color: rgba(0,0,0,0.8);
}

/* Caption text */
.text {
  color: #f2f2f2;
  font-size: 15px;
  padding: 8px 12px;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
}

/* Number text (1/3 etc) */
.numbertext {
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* The dots/bullets/indicators */
.dot {
  cursor: pointer;
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active, .dot:hover {
  background-color: #717171;
}
h2{
    text-align :center ;
    margin-top : 30px;
    display : block ;
}
/* Fading animation */
.fade {
  animation-name: fade;
  animation-duration: 1.5s;
}

@keyframes fade {
  from {opacity: .4} 
  to {opacity: 1}
}

/* On smaller screens, decrease text size */
@media only screen and (max-width: 300px) {
  .prev, .next,.text {font-size: 11px}
}

```


Well You Guessed it we create a css animation using the keyframes to make the fadin effect on the image as they disappear...

output with CSS :


![with css.jpg](https://files.peakd.com/file/peakd-hive/foxlead/23y8ekQtcMfXXE9bed5n1qLqWcAAUMPnwAo9WXujrw9pPhFH7TeT8c7bWRXDH1CUkAUjm.jpg)


Now Here is MY JAVASCRIPT :

```
<script>
    //declearing a global variable 
let slideIndex = 1;
//calling the Fumction
showSlides(slideIndex);

//declearing the prev and next btns
function slideBtn(n) {
  showSlides(slideIndex += n);
}
// declearing the slides function
function showSlides(n) {
  let i;
  //declearing the slides variable 
  let slides = document.getElementsByClassName("mySlides");

  //other words a cinditional statement which is that if since n==1 thus if 1 >1 the let n = 1
  //this is placed so thate enev though the images are just siz then the will still be able to repeat themselves 
  //thereby causing a carousel of a looping effect ...   :) 
  if (n > slides.length) {slideIndex = 1}    // for the backward
  if (n < 1) {slideIndex = slides.length}   //for the forward
  for (i = 0; i < slides.length; i++) {
    slides[i].style.display = "none";  
  }
  slideIndex++;
  if (slideIndex > slides.length) {slideIndex = 1}
  slides[slideIndex-1].style.display = "block";  
  //using the setTimeout method in javascript we can set it to continue ton repeat 
  setTimeout(showSlides, 5000); // Change image every 2 seconds
}
</script>


```

I enclosed the javascript into the script tag which makes it to work in a SFC (single-file-cpmponent VueJs terminology(front-end-framework)).

full VIEW ;


![slidesss.jpg](https://files.peakd.com/file/peakd-hive/foxlead/23xeXVzrVKsBT6hWA7LVaXF341Ef7znHgajr2nxcMgbsggLt3mUss98cLDoZ3k4iQakyp.jpg)

![onld.jpg](https://files.peakd.com/file/peakd-hive/foxlead/23xeX8drYnupRnCithHKAYN2P4ewx9jrNMr4bQK5Sd2RBbiUchEXMCzSV5rgARub3ubXW.jpg)

![dckmd.jpg](https://files.peakd.com/file/peakd-hive/foxlead/23z774XR7SDfTZHUgFiN9mmGKS92a4WDqJKNi5AhVcw8SXbC2APFckBQpPrSmqoAEp25H.jpg)

![ddijom.jpg](https://files.peakd.com/file/peakd-hive/foxlead/23xyGbYKZXXzGGKAvWS8e6JvfMT7UNNEEKHDJxPNJBpME3EPg1h7nbrT9JDjcVvVUkSjA.jpg)


Alright Guys this brings me to an end of this tutorial and ill see you nest time with a cool one Animations Usng Pure Css....



![profile.jpg](https://files.peakd.com/file/peakd-hive/foxlead/245wUQ1NcbdyE9Jm7sS4iecTXvWG7mMS3jvRRkZuYPgs9KtDMjoJssLqEsbe7pBicvwRM.jpg)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 135 others
properties (23)
authorfoxlead
permlinkautomatic-slideshow-html-css-js
categoryhive-169321
json_metadata"{"app":"peakd/2022.07.1","format":"markdown","description":"Hive Slide Show ","tags":["development","programming","hive","hivepost","post","text","article","drop","code","go"],"users":["keyframes","media"],"image":["https://files.peakd.com/file/peakd-hive/foxlead/23xeX8drYnupRnCithHKAYN2P4ewx9jrNMr4bQK5Sd2RBbiUchEXMCzSV5rgARub3ubXW.jpg","https://files.peakd.com/file/peakd-hive/foxlead/23zGXuYfaKYY2PQvcW38awLMGEAZs5AbpmFo48cKwFj4YnUdXJ5vbrgc2984pvSm6NnKd.jpg","https://files.peakd.com/file/peakd-hive/foxlead/23y8ekQtcMfXXE9bed5n1qLqWcAAUMPnwAo9WXujrw9pPhFH7TeT8c7bWRXDH1CUkAUjm.jpg","https://files.peakd.com/file/peakd-hive/foxlead/23xeXVzrVKsBT6hWA7LVaXF341Ef7znHgajr2nxcMgbsggLt3mUss98cLDoZ3k4iQakyp.jpg","https://files.peakd.com/file/peakd-hive/foxlead/23z774XR7SDfTZHUgFiN9mmGKS92a4WDqJKNi5AhVcw8SXbC2APFckBQpPrSmqoAEp25H.jpg","https://files.peakd.com/file/peakd-hive/foxlead/23xyGbYKZXXzGGKAvWS8e6JvfMT7UNNEEKHDJxPNJBpME3EPg1h7nbrT9JDjcVvVUkSjA.jpg","https://files.peakd.com/file/peakd-hive/foxlead/245wUQ1NcbdyE9Jm7sS4iecTXvWG7mMS3jvRRkZuYPgs9KtDMjoJssLqEsbe7pBicvwRM.jpg"]}"
created2022-08-10 03:06:18
last_update2022-08-10 03:06:18
depth0
children4
last_payout2022-08-17 03:06:18
cashout_time1969-12-31 23:59:59
total_payout_value1.706 HBD
curator_payout_value1.715 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,952
author_reputation1,764,784,527,290
root_title"Automatic Slideshow HTML , CSS , JS"
beneficiaries
0.
accounthive-169321
weight100
1.
accounthiveonboard
weight100
2.
accountocd
weight100
3.
accountstarstrings01
weight100
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,589,730
net_rshares4,614,183,792,197
author_curate_reward""
vote details (199)
@hivebuzz ·
Congratulations @foxlead! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

<table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@foxlead/upvoted.png?202208102149"></td><td>You received more than 1750 upvotes.<br>Your next target is to reach 2000 upvotes.</td></tr>
</table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@foxlead) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Check out the last post from @hivebuzz:**
<table><tr><td><a href="/hive-106258/@hivebuzz/hivefest-trf-2022"><img src="https://images.hive.blog/64x128/https://i.imgur.com/2371e0x.png"></a></td><td><a href="/hive-106258/@hivebuzz/hivefest-trf-2022">Hivebuzz supports the HiveFest⁷ Travel Reimbursement Fund.</a></td></tr></table>

###### Support the HiveBuzz project. [Vote](https://hivesigner.com/sign/update_proposal_votes?proposal_ids=%5B%22199%22%5D&approve=true) for [our proposal](https://peakd.com/me/proposals/199)!
properties (22)
authorhivebuzz
permlinknotify-foxlead-20220810t221957
categoryhive-169321
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2022-08-10 22:19:57
last_update2022-08-10 22:19:57
depth1
children0
last_payout2022-08-17 22:19:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,150
author_reputation369,400,933,268,717
root_title"Automatic Slideshow HTML , CSS , JS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,615,007
net_rshares0
@joebolite97 ·
Well done sir 
properties (22)
authorjoebolite97
permlinkre-foxlead-rgeznv
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2022.07.1"}
created2022-08-10 19:33:36
last_update2022-08-10 19:33:36
depth1
children1
last_payout2022-08-17 19:33:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length14
author_reputation13,174,697,412,119
root_title"Automatic Slideshow HTML , CSS , JS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,610,154
net_rshares0
@foxlead ·
Thanks Sir
properties (22)
authorfoxlead
permlinkre-joebolite97-rgf1g0
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2022.07.1"}
created2022-08-10 20:12:03
last_update2022-08-10 20:12:03
depth2
children0
last_payout2022-08-17 20:12:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length10
author_reputation1,764,784,527,290
root_title"Automatic Slideshow HTML , CSS , JS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,611,553
net_rshares0
@stemsocial ·
re-foxlead-automatic-slideshow-html-css-js-20220810t212817700z
<div class='text-justify'> <div class='pull-left'>
 <img src='https://stem.openhive.network/images/stemsocialsupport7.png'> </div>

Thanks for your contribution to the <a href='/trending/hive-196387'>STEMsocial community</a>. Feel free to join us on <a href='https://discord.gg/9c7pKVD'>discord</a> to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.&nbsp;<br />&nbsp;<br />
</div>
properties (22)
authorstemsocial
permlinkre-foxlead-automatic-slideshow-html-css-js-20220810t212817700z
categoryhive-169321
json_metadata{"app":"STEMsocial"}
created2022-08-10 21:28:18
last_update2022-08-10 21:28:18
depth1
children0
last_payout2022-08-17 21:28:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length565
author_reputation22,918,491,691,707
root_title"Automatic Slideshow HTML , CSS , JS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,613,734
net_rshares0