- This topic has 30 replies, 3 voices, and was last updated 6 years, 4 months ago by
David.
-
AuthorPosts
-
November 5, 2019 at 11:30 am #1054195
Oisin
Hi Leo,
Thanks for your help with this one. I really need to get it fixed. I recently changed the content of the menu label to this
<img src="wp-content/uploads/2019/11/Load-Labz-Facebook.svg" alt="Load Labz Facebook Profile">. If you hover your cursor just to the right of “CONTACT” in my primary nav you can see actually click through to my Facebook profile, it’s just the icon will not appear.I actually think the icon might be there but can’t be seen because it is black. When I loaded the icon using the menu-icons plugin it was automatically loaded in a white fill. I assume it was picking up on the CSS rules for the rest of the menu. Now that I’m loading it as an image it is not picking up any CSS to change it to white.
Do you think this is correct and is there some trick I can use to change this within the menu label?
***Update*** I tried edited the pathfill within the SVG file to #ffffff which changed the icon to white but it’s still not showing in my primary nav for some reason. Are you sure the menu label can handle an svg loaded this way?
Many thanks,
Johnny.
November 5, 2019 at 3:28 pm #1054318Leo
StaffCustomer SupportWhat happens if you disable lazy load?
And is this done?
https://docs.generatepress.com/article/adding-svg-logo/#allowing-wordpress-to-upload-svg-filesNovember 6, 2019 at 12:02 am #1054498Oisin
Hi Leo,
I don’t have lazy load enabled. No, I’m not sure what the CSS class is for that icon. I’ll have a play around with it now.
Johnny.
November 6, 2019 at 3:46 am #1054661David
StaffCustomer SupportIf the SVG is loaded as an
<img>you cannot style it with CSS. It has to be inline.
Easiest way to do this is use the Support SVG plugin to add WP SVG support:https://en-gb.wordpress.org/plugins/svg-support/
and enable its advanced mode. Then you include their
style-svgclass:<img class="style-svg" alt="alt-text" src="image-source.svg" />This will inline the SVG which will allow the
fillproperty and other styles to be applied.November 6, 2019 at 9:47 am #1055120Oisin
Thanks David, I’ll try that now.
November 6, 2019 at 10:02 am #1055137David
StaffCustomer SupportThe SVG method above is what i had in mind.
Worth the few extra steps if performance is the main objective as it eliminates the additional request for the font.November 6, 2019 at 10:19 am #1055150Oisin
Cheers David, for some reason I thought it was more complicated when I first read it. It’s pretty straight forward. Thanks very much for your help.
November 6, 2019 at 10:23 am #1055156David
StaffCustomer SupportGlad to be of help.
November 6, 2019 at 11:04 am #1055201Oisin
Hi David,
One last bit of help needed. I have the SVG in place but it didn’t pick up any styling so I tried targeting it with the following as a test:
.menu-item menu-item-type-custom menu-item-object-custom menu-item-1220 {
height: 20px;
width: 20px;
}I’m sure I’m missing something obvious so any advice much appreciated.
Thanks,
Johnny.
November 6, 2019 at 4:18 pm #1055386David
StaffCustomer SupportLooks like you’re missing some
.on your CSS selectors and you want to target the svg inside the menu item so this:.menu-item menu-item-type-custom menu-item-object-custom menu-item-1220should be:
.menu-item .menu-item-type-custom .menu-item-object-custom .menu-item-1220 svgIf thats not working then link me to the site and i can take a look.
You may want to look into add CSS classes to menu items – will save a lot of hassle:
https://docs.generatepress.com/article/using-the-wordpress-menu-builder/#custom-classes
November 7, 2019 at 3:58 am #1055713Oisin
Cheers David,
I added a class to both the Facebook and Twitter icons there .svg-menu-icon using the method you linked. I then used that to target the icons in the additional CSS customizer. That worked a treat, I can see that the CSS is being picked up. Thanks for the tip! For some reason the icons aren’t displaying still.
My website is loadlabz.com – really appreciate you taking a look. You can see how it’s supposed to look by visiting testinglabz.com
Warm regards,
Johnny.
November 7, 2019 at 4:16 am #1055737David
StaffCustomer SupportNeed to target the
svgelement like so:.svg-menu-icon svg { height: 20px; width: 20px; fill: #ffffff; }November 7, 2019 at 5:46 am #1055838Oisin
A rookie mistake. Thanks for all your help, everything is looking great now.
November 7, 2019 at 5:51 am #1055842David
StaffCustomer SupportGlad to be of help 🙂
November 8, 2019 at 8:24 am #1057091Oisin
***Edit*** Fixed it
-
AuthorPosts
- You must be logged in to reply to this topic.