Displaying Elements in Mobile Only | WixCreate | Wix Code - Corvid
 

Wix Tutorial - Displaying elements in mobile only with Wix Code

Wix Code can be used to display elements only in the mobile version of your site.

The basic steps to set up an element to display only in mobile are:

  • Set the element to be hidden when the page loads.

  • Use Wix Code to check if your site is being viewed on a desktop or mobile device.

  • If your site is being viewed on a mobile device, use Wix Code to display elements that are hidden on desktop.

Elements:

  • An image that we only want to display on mobile: #Image1   |   Hidden on load

Wix Code:

import wixWindow from 'wix-window';

$w.onReady(function () {
 if(wixWindow.formFactor === "Mobile"){
  $w("#Image1").show();
 }
});

Demo:

This is the image that is hidden when viewed on a desktop but is visible when viewing on a cell phone:

Websites designed by WixCreate that use the above Wix Code:

None

Official Wix Expert & Wix Agency Partner

© 2020 by WIXCreate.com

I  All Rights Reserved  I  info@wixcreate.com  I  202-640-5440

facebook-2.gif