Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Icon as menu item not working on mobile

Icon as menu item not working on mobile

Scheduled Pinned Locked Moved General Discussion
5 Posts 3 Posters 63 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cellarific
    wrote on last edited by
    #1

    Hi- I'm working on https://www.torinwoodhall.com

    I'm using a blank menu item (just Ā ), then custom CSS to add an Instagram icon as a background image for that menu item.

    .instaicon {
    background-image: url('/wp-content/themes/lay-child/images/Instagram-16x16-1.svg');
    background-repeat: no-repeat;
    background-position: left;
    margin-left: 5px;
    background-color: white;
    width:20px;
    height:20px;
    }
    .instaicon a {
    width:22px;
    display:block;
    }

    It's working great on desktop, but on mobile the menu item isn't full width and the icon doesn't display (there's just a black area around where the icon should be.

    Could you please let me know how this is best resolved?

    Many thanks

    1 Reply Last reply
    0
    • F Offline
      F Offline
      felix_rabe
      wrote on last edited by felix_rabe
      #2
       <li id="menu-item-5536" class="instaicon menu-item menu-item-type-custom menu-item-object-custom menu-item-5536">
            <a target="_blank" rel="noopener" href="https://www.instagram.com/t0zzawozza" class="_Default _Default" data-type="custom">
                 <span>&nbsp;</span>
            </a>
       </li>
      

      As you can see in the html. your <li> gets your custom icon and then the <a> has a background color in black on a mobile layout. so you kinda need to deactivate that background of <a> inside your custom <li>.

       .instaicon a {
        background-color: transparent!important;
      

      }

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Cellarific
        wrote on last edited by
        #3

        Thanks!

        Now the icon's displaying OK, but the list item has a transparent background. Any way to force that to black so it looks like the others while keeping the icon white?

        1 Reply Last reply
        0
        • arminunruhA Offline
          arminunruhA Offline
          arminunruh
          Global Moderator
          wrote on last edited by
          #4

          leave this css in for lay options → custom css & html → custom css for desktop:

          .instaicon {
          background-image: url('/wp-content/themes/lay-child/images/Instagram-16x16-1.svg');
          background-repeat: no-repeat;
          background-position: left;
          margin-left: 5px;
          background-color: white;
          width:20px;
          height:20px;
          }
          .instaicon a {
          width:22px;
          display:block;
          }
          

          put this css in css for mobile:

          .instaicon a {
                  background-image: url(/wp-content/themes/lay-child/images/Instagram-16x16-1.svg);
                  background-repeat: no-repeat;
                  background-position: left;
                  background-size: 20px;
                  margin-left: 23px;
          }
          

          your css needs to be different for mobile than for desktop

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Cellarific
            wrote on last edited by Cellarific
            #5

            Awesome- thanks, I'd missed that there was the option of different CSS for desktop & mobile. That's all working a treat now.

            In case it should help someone else in the future, I did have to make a small change to the mobile CSS to get the icon positioned correctly:

            .instaicon a {
                    background-image: url(/wp-content/themes/lay-child/images/Instagram-16x16-1.svg);
                    background-repeat: no-repeat;
                    background-position: 23px;
                    background-size: 20px;
            }
            

            Really appreciate your help :)

            1 Reply Last reply
            1
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            I also code custom websites or custom Lay features.
            šŸ’æ Email me here: šŸ’æ
            info@laytheme.com

            Before you post:
            1. When using a WordPress Cache plugin, disable it or clear your cache.
            2. Update Lay Theme and all Lay Theme Addons
            3. Disable all Plugins
            4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

            This often solves issues you might run into

            When you post:
            1. Post a link to where the problem is
            2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
            3. If the problem is difficult to explain, post screenshots / link to a video to explain it
            Online Users
            Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
            laytheme.com
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Recent
            • Tags
            • Popular
            • Users
            • Search