How do I get a slideshow only on mobile?











up vote
-4
down vote

favorite












I'm wondering how I can get a slideshow to only view on mobile. I need 3 different sections next to each other on my webpage and when width turns below 640px I need it to turn into a slideshow.
I found a webpage that has this integrated:



Normal page:
Normal page



Mobile page:
Mobile page



Can anyone help me with this?



This is the script I'm using:






<script>

var slideIndex = 1;
showSlides(slideIndex);

function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}

function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
}
</script>












share|improve this question




























    up vote
    -4
    down vote

    favorite












    I'm wondering how I can get a slideshow to only view on mobile. I need 3 different sections next to each other on my webpage and when width turns below 640px I need it to turn into a slideshow.
    I found a webpage that has this integrated:



    Normal page:
    Normal page



    Mobile page:
    Mobile page



    Can anyone help me with this?



    This is the script I'm using:






    <script>

    var slideIndex = 1;
    showSlides(slideIndex);

    function plusSlides(n) {
    showSlides(slideIndex += n);
    }
    function currentSlide(n) {
    showSlides(slideIndex = n);
    }

    function showSlides(n) {
    var i;
    var slides = document.getElementsByClassName("mySlides");
    var dots = document.getElementsByClassName("dot");
    if (n > slides.length) {slideIndex = 1}
    if (n < 1) {slideIndex = slides.length}
    for (i = 0; i < slides.length; i++) {
    slides[i].style.display = "none";
    }
    for (i = 0; i < dots.length; i++) {
    dots[i].className = dots[i].className.replace(" active", "");
    }
    slides[slideIndex-1].style.display = "block";
    dots[slideIndex-1].className += " active";
    }
    </script>












    share|improve this question


























      up vote
      -4
      down vote

      favorite









      up vote
      -4
      down vote

      favorite











      I'm wondering how I can get a slideshow to only view on mobile. I need 3 different sections next to each other on my webpage and when width turns below 640px I need it to turn into a slideshow.
      I found a webpage that has this integrated:



      Normal page:
      Normal page



      Mobile page:
      Mobile page



      Can anyone help me with this?



      This is the script I'm using:






      <script>

      var slideIndex = 1;
      showSlides(slideIndex);

      function plusSlides(n) {
      showSlides(slideIndex += n);
      }
      function currentSlide(n) {
      showSlides(slideIndex = n);
      }

      function showSlides(n) {
      var i;
      var slides = document.getElementsByClassName("mySlides");
      var dots = document.getElementsByClassName("dot");
      if (n > slides.length) {slideIndex = 1}
      if (n < 1) {slideIndex = slides.length}
      for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";
      }
      for (i = 0; i < dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
      }
      slides[slideIndex-1].style.display = "block";
      dots[slideIndex-1].className += " active";
      }
      </script>












      share|improve this question















      I'm wondering how I can get a slideshow to only view on mobile. I need 3 different sections next to each other on my webpage and when width turns below 640px I need it to turn into a slideshow.
      I found a webpage that has this integrated:



      Normal page:
      Normal page



      Mobile page:
      Mobile page



      Can anyone help me with this?



      This is the script I'm using:






      <script>

      var slideIndex = 1;
      showSlides(slideIndex);

      function plusSlides(n) {
      showSlides(slideIndex += n);
      }
      function currentSlide(n) {
      showSlides(slideIndex = n);
      }

      function showSlides(n) {
      var i;
      var slides = document.getElementsByClassName("mySlides");
      var dots = document.getElementsByClassName("dot");
      if (n > slides.length) {slideIndex = 1}
      if (n < 1) {slideIndex = slides.length}
      for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";
      }
      for (i = 0; i < dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
      }
      slides[slideIndex-1].style.display = "block";
      dots[slideIndex-1].className += " active";
      }
      </script>








      <script>

      var slideIndex = 1;
      showSlides(slideIndex);

      function plusSlides(n) {
      showSlides(slideIndex += n);
      }
      function currentSlide(n) {
      showSlides(slideIndex = n);
      }

      function showSlides(n) {
      var i;
      var slides = document.getElementsByClassName("mySlides");
      var dots = document.getElementsByClassName("dot");
      if (n > slides.length) {slideIndex = 1}
      if (n < 1) {slideIndex = slides.length}
      for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";
      }
      for (i = 0; i < dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
      }
      slides[slideIndex-1].style.display = "block";
      dots[slideIndex-1].className += " active";
      }
      </script>





      <script>

      var slideIndex = 1;
      showSlides(slideIndex);

      function plusSlides(n) {
      showSlides(slideIndex += n);
      }
      function currentSlide(n) {
      showSlides(slideIndex = n);
      }

      function showSlides(n) {
      var i;
      var slides = document.getElementsByClassName("mySlides");
      var dots = document.getElementsByClassName("dot");
      if (n > slides.length) {slideIndex = 1}
      if (n < 1) {slideIndex = slides.length}
      for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";
      }
      for (i = 0; i < dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
      }
      slides[slideIndex-1].style.display = "block";
      dots[slideIndex-1].className += " active";
      }
      </script>






      javascript html css media-queries slideshow






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 at 15:48

























      asked Nov 22 at 15:31









      Rick van Beckhoven

      11




      11
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          you have to add id if not already existe to your tag, exemple id="slider" and add this code to your style:



          #slider {
          display: none;
          }

          @media only screen and (max-width: 768px) {
          #slider {
          display: block;
          }
          }


          good luck.






          share|improve this answer





















          • When I do this. On the normal page I'm only able to see one of the 3 slider components.
            – Rick van Beckhoven
            Nov 22 at 16:27










          • can you add a screenshot ?
            – hamzanatek
            Nov 22 at 16:35


















          up vote
          0
          down vote













          Option 1
          Use media queries to show hide the slider component as per the screen size



          @media only screen and (max-width: 640px) {
          #slider_component {
          display: block;
          }
          }
          #slider_component {
          display: none;
          }


          Option 2



          If you are using any of the css frameworks like bootstrap or foundation, you can attach hooks to show/hide elements on the page as per the screen size. Check out their docs here.






          share|improve this answer





















          • When I do this. On the normal page I'm only able to see one of the 3 slider components.
            – Rick van Beckhoven
            Nov 22 at 15:54










          • Is it possible to only toggle the script when max width of a page is below a certain lvl?
            – Rick van Beckhoven
            Nov 22 at 16:01










          • Yes, you can do this javascript as well. You can toggle your slider based on the desired screen size by checking screen.height and screen.width
            – Abhidev
            Nov 23 at 15:14













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434169%2fhow-do-i-get-a-slideshow-only-on-mobile%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          you have to add id if not already existe to your tag, exemple id="slider" and add this code to your style:



          #slider {
          display: none;
          }

          @media only screen and (max-width: 768px) {
          #slider {
          display: block;
          }
          }


          good luck.






          share|improve this answer





















          • When I do this. On the normal page I'm only able to see one of the 3 slider components.
            – Rick van Beckhoven
            Nov 22 at 16:27










          • can you add a screenshot ?
            – hamzanatek
            Nov 22 at 16:35















          up vote
          0
          down vote













          you have to add id if not already existe to your tag, exemple id="slider" and add this code to your style:



          #slider {
          display: none;
          }

          @media only screen and (max-width: 768px) {
          #slider {
          display: block;
          }
          }


          good luck.






          share|improve this answer





















          • When I do this. On the normal page I'm only able to see one of the 3 slider components.
            – Rick van Beckhoven
            Nov 22 at 16:27










          • can you add a screenshot ?
            – hamzanatek
            Nov 22 at 16:35













          up vote
          0
          down vote










          up vote
          0
          down vote









          you have to add id if not already existe to your tag, exemple id="slider" and add this code to your style:



          #slider {
          display: none;
          }

          @media only screen and (max-width: 768px) {
          #slider {
          display: block;
          }
          }


          good luck.






          share|improve this answer












          you have to add id if not already existe to your tag, exemple id="slider" and add this code to your style:



          #slider {
          display: none;
          }

          @media only screen and (max-width: 768px) {
          #slider {
          display: block;
          }
          }


          good luck.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 at 15:36









          hamzanatek

          19610




          19610












          • When I do this. On the normal page I'm only able to see one of the 3 slider components.
            – Rick van Beckhoven
            Nov 22 at 16:27










          • can you add a screenshot ?
            – hamzanatek
            Nov 22 at 16:35


















          • When I do this. On the normal page I'm only able to see one of the 3 slider components.
            – Rick van Beckhoven
            Nov 22 at 16:27










          • can you add a screenshot ?
            – hamzanatek
            Nov 22 at 16:35
















          When I do this. On the normal page I'm only able to see one of the 3 slider components.
          – Rick van Beckhoven
          Nov 22 at 16:27




          When I do this. On the normal page I'm only able to see one of the 3 slider components.
          – Rick van Beckhoven
          Nov 22 at 16:27












          can you add a screenshot ?
          – hamzanatek
          Nov 22 at 16:35




          can you add a screenshot ?
          – hamzanatek
          Nov 22 at 16:35












          up vote
          0
          down vote













          Option 1
          Use media queries to show hide the slider component as per the screen size



          @media only screen and (max-width: 640px) {
          #slider_component {
          display: block;
          }
          }
          #slider_component {
          display: none;
          }


          Option 2



          If you are using any of the css frameworks like bootstrap or foundation, you can attach hooks to show/hide elements on the page as per the screen size. Check out their docs here.






          share|improve this answer





















          • When I do this. On the normal page I'm only able to see one of the 3 slider components.
            – Rick van Beckhoven
            Nov 22 at 15:54










          • Is it possible to only toggle the script when max width of a page is below a certain lvl?
            – Rick van Beckhoven
            Nov 22 at 16:01










          • Yes, you can do this javascript as well. You can toggle your slider based on the desired screen size by checking screen.height and screen.width
            – Abhidev
            Nov 23 at 15:14

















          up vote
          0
          down vote













          Option 1
          Use media queries to show hide the slider component as per the screen size



          @media only screen and (max-width: 640px) {
          #slider_component {
          display: block;
          }
          }
          #slider_component {
          display: none;
          }


          Option 2



          If you are using any of the css frameworks like bootstrap or foundation, you can attach hooks to show/hide elements on the page as per the screen size. Check out their docs here.






          share|improve this answer





















          • When I do this. On the normal page I'm only able to see one of the 3 slider components.
            – Rick van Beckhoven
            Nov 22 at 15:54










          • Is it possible to only toggle the script when max width of a page is below a certain lvl?
            – Rick van Beckhoven
            Nov 22 at 16:01










          • Yes, you can do this javascript as well. You can toggle your slider based on the desired screen size by checking screen.height and screen.width
            – Abhidev
            Nov 23 at 15:14















          up vote
          0
          down vote










          up vote
          0
          down vote









          Option 1
          Use media queries to show hide the slider component as per the screen size



          @media only screen and (max-width: 640px) {
          #slider_component {
          display: block;
          }
          }
          #slider_component {
          display: none;
          }


          Option 2



          If you are using any of the css frameworks like bootstrap or foundation, you can attach hooks to show/hide elements on the page as per the screen size. Check out their docs here.






          share|improve this answer












          Option 1
          Use media queries to show hide the slider component as per the screen size



          @media only screen and (max-width: 640px) {
          #slider_component {
          display: block;
          }
          }
          #slider_component {
          display: none;
          }


          Option 2



          If you are using any of the css frameworks like bootstrap or foundation, you can attach hooks to show/hide elements on the page as per the screen size. Check out their docs here.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 at 15:41









          Abhidev

          4,36151525




          4,36151525












          • When I do this. On the normal page I'm only able to see one of the 3 slider components.
            – Rick van Beckhoven
            Nov 22 at 15:54










          • Is it possible to only toggle the script when max width of a page is below a certain lvl?
            – Rick van Beckhoven
            Nov 22 at 16:01










          • Yes, you can do this javascript as well. You can toggle your slider based on the desired screen size by checking screen.height and screen.width
            – Abhidev
            Nov 23 at 15:14




















          • When I do this. On the normal page I'm only able to see one of the 3 slider components.
            – Rick van Beckhoven
            Nov 22 at 15:54










          • Is it possible to only toggle the script when max width of a page is below a certain lvl?
            – Rick van Beckhoven
            Nov 22 at 16:01










          • Yes, you can do this javascript as well. You can toggle your slider based on the desired screen size by checking screen.height and screen.width
            – Abhidev
            Nov 23 at 15:14


















          When I do this. On the normal page I'm only able to see one of the 3 slider components.
          – Rick van Beckhoven
          Nov 22 at 15:54




          When I do this. On the normal page I'm only able to see one of the 3 slider components.
          – Rick van Beckhoven
          Nov 22 at 15:54












          Is it possible to only toggle the script when max width of a page is below a certain lvl?
          – Rick van Beckhoven
          Nov 22 at 16:01




          Is it possible to only toggle the script when max width of a page is below a certain lvl?
          – Rick van Beckhoven
          Nov 22 at 16:01












          Yes, you can do this javascript as well. You can toggle your slider based on the desired screen size by checking screen.height and screen.width
          – Abhidev
          Nov 23 at 15:14






          Yes, you can do this javascript as well. You can toggle your slider based on the desired screen size by checking screen.height and screen.width
          – Abhidev
          Nov 23 at 15:14




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434169%2fhow-do-i-get-a-slideshow-only-on-mobile%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          What visual should I use to simply compare current year value vs last year in Power BI desktop

          How to ignore python UserWarning in pytest?

          Alexandru Averescu