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>
javascript html css media-queries slideshow
add a comment |
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>
javascript html css media-queries slideshow
add a comment |
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>
javascript html css media-queries slideshow
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
javascript html css media-queries slideshow
edited Nov 22 at 15:48
asked Nov 22 at 15:31
Rick van Beckhoven
11
11
add a comment |
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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