{"id":3585,"date":"2017-08-24T07:19:30","date_gmt":"2017-08-24T11:19:30","guid":{"rendered":"https:\/\/www.searchenginegenie.com\/web-design-blog\/?p=3585"},"modified":"2018-03-09T03:15:23","modified_gmt":"2018-03-09T07:15:23","slug":"how-to-create-a-slideshow-with-css-and-javascript","status":"publish","type":"post","link":"https:\/\/www.searchenginegenie.com\/web-design-blog\/how-to-create-a-slideshow-with-css-and-javascript\/","title":{"rendered":"How to create a Slideshow with CSS and JavaScript"},"content":{"rendered":"<p><a name=\"imageclose-3586\"><div class=\"lb-album\"><a href=\"#image-3586\"><img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2017\/08\/gif-1.gif\"  class=\"aligncenter size-full wp-image-3625\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-3586\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-3586\">\r\n                   <img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2017\/08\/gif-1.gif\" alt=\"image-3586\">\r\n                   <\/div><\/a><strong>Step:1<\/strong><\/p>\n<p>Now we are going to create a slideshow using html, css and java script.\u00a0 HTML is the standard markup languages for creating web pages. The html coding are as follows:<\/p>\n<div style=\"color: #600;\">&lt;!DOCTYPE html PUBLIC &#8220;-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN&#8221; &#8220;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd&#8221;&gt;<br \/>\n&lt;html xmlns=&#8221;http:\/\/www.w3.org\/1999\/xhtml&#8221;&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;style.css&#8221; \/&gt;<br \/>\n&lt;script src=&#8221;blog.js&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=utf-8&#8243; \/&gt;<br \/>\n&lt;title&gt;Untitled Document&lt;\/title&gt;<br \/>\n&lt;\/head&gt;&lt;body&gt;<br \/>\n&lt;div class=&#8221;slideshow-container&#8221;&gt;<br \/>\n&lt;div class=&#8221;mySlides fade&#8221;&gt;<br \/>\n&lt;div class=&#8221;numbertext&#8221;&gt;1 \/ 3&lt;\/div&gt;<br \/>\n&lt;img src=&#8221;img_nature_wide.jpg&#8221; style=&#8221;width:100%&#8221;&gt;<br \/>\n&lt;div class=&#8221;text&#8221;&gt;Caption Text&lt;\/div&gt;<br \/>\n&lt;\/div&gt;&lt;div class=&#8221;mySlides fade&#8221;&gt;<br \/>\n&lt;div class=&#8221;numbertext&#8221;&gt;2 \/ 3&lt;\/div&gt;<br \/>\n&lt;img src=&#8221;img_nature_wide.jpg&#8221; style=&#8221;width:100%&#8221;&gt;<br \/>\n&lt;div class=&#8221;text&#8221;&gt;Caption Two&lt;\/div&gt;<br \/>\n&lt;\/div&gt;&lt;div class=&#8221;mySlides fade&#8221;&gt;<br \/>\n&lt;div class=&#8221;numbertext&#8221;&gt;3 \/ 3&lt;\/div&gt;<br \/>\n&lt;imgsrc=&#8221;img_nature_wide.jpg&#8221; style=&#8221;width:100%&#8221;&gt;<br \/>\n&lt;div class=&#8221;text&#8221;&gt;Caption Three&lt;\/div&gt;<\/p>\n<div style=\"color: #600;\">&lt;a class=&#8221;prev&#8221; onclick=&#8221;plusSlides(-1)&#8221;&gt;&amp;#10094;&lt;\/a&gt;<br \/>\n&lt;a class=&#8221;next&#8221; onclick=&#8221;plusSlides(1)&#8221;&gt;&amp;#10095;&lt;\/a&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;br&gt;<\/p>\n<div style=\"color: #600;\">&lt;div style=&#8221;text-align:center&#8221;&gt;<br \/>\n&lt;span class=&#8221;dot&#8221; onclick=&#8221;currentSlide(1)&#8221;&gt;&lt;\/span&gt;<br \/>\n&lt;span class=&#8221;dot&#8221; onclick=&#8221;currentSlide(2)&#8221;&gt;&lt;\/span&gt;<br \/>\n&lt;span class=&#8221;dot&#8221; onclick=&#8221;currentSlide(3)&#8221;&gt;&lt;\/span&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/div>\n<\/div>\n<p><strong>Step:2<\/strong><\/p>\n<p>Now css followed by html. Css is a multiple page derived from multiple sources with a defined order of Precedence<\/p>\n<p>where the definition of any style element conflict.<\/p>\n<div style=\"color: #600;\">*<\/p>\n<div style=\"color: #600;\">\n<p>{box-sizing:border-box}<\/p>\n<div style=\"color: #600;\">\/* Slideshow container *\/<br \/>\n.slideshow-container {<br \/>\nmax-width: 1000px;<br \/>\nposition: relative;<br \/>\nmargin: auto;<br \/>\n}<\/p>\n<div style=\"color: #600;\">.mySlides {<br \/>\ndisplay: none;<br \/>\n}<\/p>\n<div style=\"color: #600;\">\/* Next &amp; previous buttons *\/<br \/>\n.prev, .next {<br \/>\ncursor: pointer;<br \/>\nposition: absolute;<br \/>\ntop: 50%;<br \/>\nwidth: auto;<br \/>\nmargin-top: -22px;<br \/>\npadding: 16px;<br \/>\ncolor: white;<br \/>\nfont-weight: bold;<br \/>\nfont-size: 18px;<br \/>\ntransition: 0.6s ease;<br \/>\nborder-radius: 0 3px 3px 0;<br \/>\n}<\/p>\n<div style=\"color: #600;\">\/* Position the &#8220;next button&#8221; to the right *\/<br \/>\n.next {<br \/>\nright: 0;<br \/>\nborder-radius: 3px 0 0 3px;<br \/>\n}<\/p>\n<div style=\"color: #600;\">\/* On hover, add a black background color with a little bit see-through *\/<br \/>\n.prev:hover, .next:hover {<br \/>\nbackground-color: rgba(0,0,0,0.8);<br \/>\n}<\/p>\n<div style=\"color: #600;\">\/* Caption text *\/<br \/>\n.text {<br \/>\ncolor: #f2f2f2;<br \/>\nfont-size: 15px;<br \/>\npadding: 8px 12px;<br \/>\nposition: absolute;<br \/>\nbottom: 8px;<br \/>\nwidth: 100%;<br \/>\ntext-align: center;<br \/>\n}<\/p>\n<div style=\"color: #600;\">\/* Number text (1\/3 etc) *\/<br \/>\n.numbertext {<br \/>\ncolor: #f2f2f2;<br \/>\nfont-size: 12px;<br \/>\npadding: 8px 12px;<br \/>\nposition: absolute;<br \/>\ntop: 0;<br \/>\n}<\/p>\n<div style=\"color: #600;\">\/* The dots\/bullets\/indicators *\/<br \/>\n.dot {<br \/>\ncursor:pointer;<br \/>\nheight: 13px;<br \/>\nwidth: 13px;<br \/>\nmargin: 0 2px;<br \/>\nbackground-color: #bbb;<br \/>\nborder-radius: 50%;<br \/>\ndisplay: inline-block;<br \/>\ntransition: background-color 0.6s ease;<br \/>\n}<\/p>\n<div style=\"color: #600;\">.active, .dot:hover {<br \/>\nbackground-color: #717171;<br \/>\n}<\/p>\n<div style=\"color: #600;\">\/* Fading animation *\/<br \/>\n.fade {<br \/>\n-webkit-animation-name: fade;<br \/>\n-webkit-animation-duration: 1.5s;<br \/>\nanimation-name: fade;<br \/>\nanimation-duration: 1.5s;<br \/>\n}<\/p>\n<div style=\"color: #600;\">@-webkit-keyframes fade {<br \/>\nfrom {opacity: .4}<br \/>\nto {opacity: 1}<br \/>\n}<\/p>\n<div style=\"color: #600;\">@keyframes fade {<br \/>\nfrom {opacity: .4}<br \/>\nto {opacity: 1}<br \/>\n}<\/div>\n<p><strong>Step:3<\/strong><\/p>\n<p>Next step is to add java script.Java script is an object oriented programming language used to create interactive effects within web browser.<\/p>\n<div style=\"color: #600;\">var slideIndex = 1;<br \/>\nshowSlides(slideIndex);function plusSlides(n) {<br \/>\nshowSlides(slideIndex += n);<br \/>\n}<\/p>\n<div style=\"color: #600;\">function currentSlide(n) {<br \/>\nshowSlides(slideIndex = n);<br \/>\n}<\/p>\n<div style=\"color: #600;\">function showSlides(n) {<br \/>\nvar i;<br \/>\nvar slides = document.getElementsByClassName(&#8220;mySlides&#8221;);<br \/>\nvar dots = document.getElementsByClassName(&#8220;dot&#8221;);<br \/>\nif (n &gt; slides.length) {slideIndex = 1}<br \/>\nif (n &lt; 1) {slideIndex = slides.length}<br \/>\nfor (i = 0; i &lt; slides.length; i++) {<br \/>\nslides[i].style.display = &#8220;none&#8221;;<br \/>\n}<br \/>\nfor (i = 0; i &lt; dots.length; i++) {<br \/>\ndots[i].className = dots[i].className.replace(&#8221; active&#8221;, &#8220;&#8221;);<br \/>\n}<br \/>\nslides[slideIndex-1].style.display = &#8220;block&#8221;;<br \/>\ndots[slideIndex-1].className += &#8221; active&#8221;;<br \/>\n}<\/div>\n<div><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Step:1 Now we are going to create a slideshow using html, css and java script.\u00a0 HTML is the standard markup languages for creating web pages. The html coding are as follows: &lt;!DOCTYPE html PUBLIC &#8220;-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN&#8221; &#8220;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd&#8221;&gt; &lt;html xmlns=&#8221;http:\/\/www.w3.org\/1999\/xhtml&#8221;&gt; &lt;head&gt; &lt;link rel=&#8221;stylesheet&#8221; href=&#8221;style.css&#8221; \/&gt; &lt;script src=&#8221;blog.js&#8221;&gt;&lt;\/script&gt; &lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=utf-8&#8243; \/&gt; &lt;title&gt;Untitled Document&lt;\/title&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,5,1],"tags":[163,175],"class_list":["post-3585","post","type-post","status-publish","format-standard","hentry","category-photoshop-tips","category-web-design-tips","category-whats-trending-web-design","tag-photoshop","tag-webdesign-tips"],"_links":{"self":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/3585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/comments?post=3585"}],"version-history":[{"count":30,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/3585\/revisions"}],"predecessor-version":[{"id":3653,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/3585\/revisions\/3653"}],"wp:attachment":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/media?parent=3585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/categories?post=3585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/tags?post=3585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}