1

is it possible that move an element for the desktop only or mobile-only using xml or any other solution of it.

2
  • Maybe you can do this via Javascript. or Hide and show using CSS.
    – Nits
    Sep 24, 2019 at 18:01
  • Should be easy in CSS based on the viewport size. Doing it otherwise would seem to require complicated and unreliable browser detection.
    – jiheison
    Sep 24, 2019 at 19:23

3 Answers 3

1

You can do by CSS and Javascript both, easy you can use Simple CSS.

#content {display: block;} 

@media screen and (max-width: 768px) { 
#content {display: none;}
}
2
  • The scenario is that I need the same div content for desktop and mobile just need to change the placement of that div. Also, I don't want to duplicate the code. Sep 26, 2019 at 5:38
  • I have updated the css Sep 26, 2019 at 6:46
1

Not possible in XML. Display the element two times using xml, one for mobile and another one for desktop where you want

Using @sangeeta's answer you can display like

.mobile-element {display: none;} 

@media screen and (max-width: 768px) { 
    .desktop-element {display: none;}
}
0

You can do this by html and simple jQuery also:

<div class="custom" style="display:none;">Your html part </div>
$(document).ready(function(){
   var width = $(window).width();
   if(width < 768){  //for mobile only      
       $('.custom').show();        
   }
});

Here window.width function works as below:

If you want to display for Mobile: use window width "< 768". If you want to display for Tablet/desktop devices: use window width "> 767".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.