- This topic has 11 replies, 2 voices, and was last updated 5 years, 10 months ago by
Tom.
-
AuthorPosts
-
May 5, 2020 at 12:53 pm #1271096
Greg
Hi guys
Not sure if this is possible with custom CSS, but would there be a way to set a fallback gradient for a header element? Just as I have a header background image with a gradient, so would be useful to replicate the gradient in the CSS when a featured image hasn’t been loaded – I know I can set the fallback image, but a gradient if possible would be ideal.
Thanks
GregMay 5, 2020 at 4:42 pm #1271292Tom
Lead DeveloperLead DeveloperHi there,
It’s not possible in the settings at the moment.
You could use custom CSS, but it would have to be added before the CSS output by the Element itself, or it would overwrite the Element CSS and the settings wouldn’t work.
Let me know if you need more info 🙂
May 6, 2020 at 1:51 am #1271627Greg
If you could give me an example of how to do that, that would be awesome.
Thanks
GregMay 6, 2020 at 9:43 am #1272385Tom
Lead DeveloperLead DeveloperFor sure, would this only be for one specific Element or would this apply to all Header elements?
May 6, 2020 at 10:20 am #1272472Greg
Thanks Tom, one specific element if that’s possible.
is there a way to set it up with a custom element class or not, based on your previous reply?
Thanks
GregMay 6, 2020 at 5:06 pm #1272919Tom
Lead DeveloperLead DeveloperYou could try something like this..
add_action( 'wp_enqueue_scripts', function() { $css = '.page-hero { background-image: linear...etc }'; wp_add_inline_style( 'generate-style', $css ); }, 60 );It’s not possible to use the custom class as the built-in CSS uses a simple
.page-heroselector.May 7, 2020 at 2:44 am #1273318Greg
Perfect, that’s worked just as needed, thanks as ever!
May 7, 2020 at 10:06 am #1274131Tom
Lead DeveloperLead DeveloperGlad I could help! 🙂
May 14, 2020 at 9:52 am #1284540Greg
Hi Tom,
I’ve only just realised but this isn’t working as I had hoped, it shows in the inspect CSS rules on the site, but if I remove the background image it doesn’t actually show the gradient – even though I can see the CSS for it there.
If I set the fallback CSS to !important; then it does show but overwrites the element styling/background image – any thoughts?
Thanks
GregMay 14, 2020 at 8:14 pm #1285069Tom
Lead DeveloperLead DeveloperAny chance I can check it out? Hard to tell without inspecting the page.
May 16, 2020 at 1:36 pm #1287750Greg
Hi Tom
Just realised what was causing the issue – I still had a background colour on the element header overwriting the snippet CSS, so removing that has fixed it.
I also figured out if I just change the class used in the snippet to a class I’ve added to the header, and then duplicate the snippet with the other gradients, I can get fallback gradients for all the header elements I’ve got 🙂
Thanks
GregMay 16, 2020 at 3:09 pm #1287834Tom
Lead DeveloperLead DeveloperAwesome, glad you got it sorted 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.