Display a different logo on mobile and desktop?

前端 未结 5 1735
执笔经年
执笔经年 2021-01-06 07:51

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 lin

5条回答
  •  半阙折子戏
    2021-01-06 08:14

    You can put both images in the element, and show / hide with CSS media queries. For example...

    HTML:

    
    

    CSS:

    @media all and (min-width: 768px) {
      .hidden-desktop {
        display: none !important;
      }
    }
    
    @media all and (max-width: 767px) {
      .hidden-mobile {
        display: none !important;
      }
    }
    

    If this is a project you're working on from scratch, consider using a front end framework like Bootstrap - there are plenty of great utility classes to handle responsive functionality.

提交回复
热议问题