0

I'm trying to put a logo on a desktop, which comes out perfect, but when I open it up to see how it looks on my phone it looks awful, it's too big and is out of the screen. So what I need is a code that provides me the ability to have different codes on mobile and desktop, for the logo. To put it simpler I need a code that is only shown on mobile and doesn't appear on desktop, while still having the properties of the logo on the desktop, and I can alter the properties on mobile.

I really appreciate any help you can provide.

Webanayil
  • 1
  • 2

1 Answers1

-1

If I read your question correctly, you want code that will only run if one is using a mobile browser. While this isn't perfect, these are accurate for the vast majority of browsers:

if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
    // user is on mobile
} else { 
    // user is on desktop
}

this will also check based on the size of the viewport (this is less accurate, because a desktop window can be resized to trick this):

if (window.innerHeight > 750) {
    // user is on mobile
} else { 
    // user is on desktop
}

Providing a code example could also help clarify if this answer isn't helpful for you.

Pufferfishe
  • 139
  • 1
  • 7