0

I want to show these 4 buttons in a row in desktop mode and show carousel like this only for mobile viewenter image description here The first pic is for mobile view and the second pic is for pc view Here is the link to my code https://jsfiddle.net/FODraciel/wehc8ryv/4/ I am trying with javascript and tried some steps which were set width technique but it does not work. Any idea of how to do it? I have tried some steps like this

window.onload=function(){
w = document.documentElement.clientWidth || document.body.clientWidth || window.innerWidth;
var targetWidth = 768;
if ( w >= targetWidth) {     
  //Add your javascript for screens wider than or equal to 768 here
}
else {
  //Add your javascript for screens smaller than 768 here
}  

};

enter image description here

Alan
  • 21
  • 4
  • Does this answer your question? [What is the best way to detect a mobile device?](https://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-device) – ATP Jan 05 '21 at 18:44
  • This looks like an XY-problem, there's probably much more efficient solution to your actual problem than load different scripts depending on screen width of the client (which can be changed during a session). Take a look at CSS solutions and [Media Queries](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries). – Teemu Jan 05 '21 at 18:57

0 Answers0