• support@answerspoint.com

How to display a different logo on mobile and desktop?

627

I want to change the logo on my header on a mobile. This is the code from the current header that shows up on both the desktop and the mobile (on desktop it is the link back to the home screen). Is there any easy way of changing it on just the mobile version?

1Answer


0

If you want to show different logo on different divice(like mobile and desktop) You can use a media query and selectively show/hide elements. Your html would have both logos in the markup, and your CSS would define which logo is shown depending on screen size.

Example is given below:

<style>
  /* hide mobile version by default */
  .logo .mobile {
    display: none;
  }
  /* when screen is less than 600px wide
     show mobile version and hide desktop */
  @media (max-width: 600px) {
    .logo .mobile {
      display: block;
    }
    .logo .desktop {
      display: none;
    }
  }
</style>
<div class="logo_div">
  <img src="/images/logo_desktop.png" class="desktop" />
  <img src="/images/logo_mobile.png" class="mobile />
</div>

 

  • answered 1 year ago
  • Community  wiki

Your Answer

    Facebook Share