Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display a different logo on mobile and desktop?

Tags:

html

css

mobile

I'm looking 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's the link back to the home screen). Is there any easy way of changing it on just the mobile version?

HTML:

<div id="mainlogo">
<a class="main logo" href="http://sheisbiddy.com/home/" title="Main Logo" alt="main logo">
<img src="http://sheisbiddy.com/wp-content/uploads/2016/01/SHEISBIDDY-main-logo-smaller-6.png" border="0" alt="" />
</a> 

CSS:

#mainlogo {text-align:center;}

Appreciate it guys!

like image 251
Ionamaroq Avatar asked Jan 25 '16 03:01

Ionamaroq


People also ask

How do I change the mobile logo in WordPress?

The procedure is simple. Log in to your WordPress dashboard and go to Appearance > Customize. After you click on the WordPress Theme Customizer and open it, you will see all the options in the left-hand menu. There might be some variations in the options that are offered depending on the theme you're using.


2 Answers

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.

For example:

<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">
  <img src="/images/logo_desktop.png" class="desktop" />
  <img src="/images/logo_mobile.png" class="mobile />
</div>
like image 191
umang Avatar answered Oct 04 '22 14:10

umang


If you are using Bootstrap then I have a very simple solution by only using a few Bootstrap classes :

<div id="mainlogo">
 <img src="/images/logo_desktop.png" class="d-none d-lg-block" />
 <img src="/images/logo_mobile.png" class="d-lg-none" />
</div>

You can see the details here: https://getbootstrap.com/docs/4.0/utilities/display/

like image 40
ikonuk Avatar answered Oct 04 '22 15:10

ikonuk