-
AuthorPosts
-
January 31, 2023 at 5:59 pm #1396073
Hello.
i want the color section to have a specific Balckground color, so i made it in css. (see below)
But now, I cant put a Picture in the Background on top of it. The gradient disappears when i load a picture to be in the background. But I would like to also have a picture in the Background on top.
Can I add this picture in my code?.hintergrund{
background: linear-gradient(
to top,
#8D005B 0%,
#8D005B 90%,
black 50%,
black 100%
)February 1, 2023 at 3:41 am #1396117Hi Monika,
It should work using this format (use rgba for colors and make sure that the colors are a bit transparent):
.hintergrund { background-image: linear-gradient(direction, color-stop1, color-stop2, ...), url('url'); }
For further information, please check: https://www.geeksforgeeks.org/css-combine-background-image-with-gradient-overlay/
Another workaround is to use a background image, then add this CSS code (just change the opacity value as you see fit (value is from 0-1):
.hintergrund { position: relative; } .hintergrund:before { background: linear-gradient( to top, #8D005B 0%, #8D005B 90%, black 50%, black 100% ); content: ''; display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0.5; }
Best regards,
NikkoFebruary 1, 2023 at 8:03 am #1396152Hey Nikko,
thank you!
I’m almost there ;)
The picture which i want to be in the Background should be above the gradient.
Now its behind.
How can i change this?Cheers
MonikaFebruary 1, 2023 at 10:33 am #1396177Hi Monika,
I don’t seem to see the image.
Can you give us a mockup or screenshot of what you want to achieve? since the image is foreground I believe it maybe better to use the code you used before and let’s just add an image element on top of the color section and maybe we’ll just need to re-position it.Best regards,
NikkoFebruary 1, 2023 at 8:09 pm #1396288Now You can see the picture, because I made the gradient transparent.
The picture is behind the gradient, but I want it to be on the top of the gradient.
Is this possible?February 1, 2023 at 8:48 pm #1396290https://webers-testseite.de/multiple-background-images/
the order of naming in the rule determines the layer order !
a background-color had to be placed in the rule as lastFebruary 1, 2023 at 9:04 pm #1396291Thank you Guenni,
but i would like to upload the picture in the Avia Builder, because I need the different options like “parallax, scoll” etc for further pictures I would like to show on next pages. Uploading each picure with css would be a lot of work.
Is’nt there an other possibility to tell the Background to be in the Back?February 2, 2023 at 4:35 am #1396323Hi Monika,
Guenni is correct, you can just change the order:
.hintergrund { background: url(REPLACE_URL), linear-gradient(to top,#8D005A 0%,#8D005B 90%,black 50%,black 100%); }
Is’nt there an other possibility to tell the Background to be in the Back?
Unfortunately, CSS doesn’t seem to have a way to do that, the workaround would probably be to write some js code that will do what you want.Best regards,
NikkoFebruary 2, 2023 at 7:55 am #1396337But the “gradient” only makes sense if the other background image does not hide this gradient. Is there a png over it then?
Can you show a schematic how this should look like?February 2, 2023 at 8:41 am #1396340if it is always the same gradient you like to insert – then you can add it via jQuery script
f.e.: a color-section with custom class: add-gradientfunction add_gradient_to_section_bg_image() { ?> <script type="text/javascript"> window.addEventListener("DOMContentLoaded", function () { (function($){ $('.avia-section.add-gradient').each(function() { var bgImg = $(this).css('background-image'); var bgPos = $(this).css('background-position'); if($(this).hasClass('av-parallax-section')){ $(this).css('background-image', 'linear-gradient( to top, #8D005B 0%, #8D005B 90%, black 50%, black 100% )'); $(this).find('.av-parallax-inner').css('background-color', 'transparent'); } if($(this).hasClass('avia-bg-style-fixed')){ var headerHeight = $("#header").height(); $(this).css({ 'background-image' : ''+bgImg+' ,linear-gradient( to top, #8D005B 0%, #8D005B 90%, black 50%, black 100% )', 'background-position' : ' '+bgPos+' , 0px '+headerHeight+'px', 'background-color' : 'black', }); } else { $(this).css('background-image', ''+bgImg+' ,linear-gradient( to top, #8D005B 0%, #8D005B 90%, black 50%, black 100% )'); } }); })(jQuery); }); </script> <?php } add_action('wp_footer', 'add_gradient_to_section_bg_image');
But: but the background-repeat/background-size will be the same as the alb settings for the image. So if you like to have different settings for the gradient – we had to add additional script.
for example: for fixed positioning we had to shift the gradient from top to header-height distance if the section is the first elementFebruary 2, 2023 at 11:59 am #1396371Or – if you like to have that “gradient” generated from background-color of the section to black :
https://enfold.webers-webdesign.de/test5/February 2, 2023 at 1:24 pm #1396382Thank you Guenni,
I’ll try to put the jQuery in the Functions.php.
I’ll just paste it at the end of it, right?
And i’ll name the Color Section “add-gradient”.perhaps that will work.
Cheers
MonikaFebruary 2, 2023 at 1:26 pm #1396383you do not have a child-theme in use?
for the custom class there is an extra input field on the advanced tab – developer settings : custom css class
But insert it without a dot in frontif not – try to place it at the end of the parent functions.php just before:
// here is a good place for it require_once( 'functions-enfold.php' );
there is an extra comment on that :
/* * register custom functions that are not related to the framework but necessary for the theme to run */
February 2, 2023 at 1:34 pm #1396384THAT WORKED!!
Nice! Im so happy
Thank you very much for this amazing support here :))February 2, 2023 at 1:37 pm #1396385but just one moment : i change the snippet a bit. …
#because the else clause lead to double insertion on parallax mode.
so here is a corrected snippet:function add_gradient_to_section_bg_image() { ?> <script type="text/javascript"> window.addEventListener("DOMContentLoaded", function () { (function($){ $('.avia-section.add-gradient').each(function() { var bgImg = $(this).css('background-image'); var bgPos = $(this).css('background-position'); if($(this).hasClass('avia-bg-style-parallax')){ $(this).css('background-image', 'linear-gradient( to top, #8D005B 0%, #8D005B 90%, black 50%, black 100% )'); $(this).find('.av-parallax-inner').css('background-color', 'transparent'); } if($(this).hasClass('avia-bg-style-fixed')){ var headerHeight = $("#header").height(); $(this).css({ 'background-image' : ''+bgImg+' ,linear-gradient( to top, #8D005B 0%, #8D005B 90%, black 50%, black 100% )', 'background-position' : ' '+bgPos+' , 0px '+headerHeight+'px', 'background-color' : 'black', }); } if($(this).hasClass('avia-bg-style-scroll')){ $(this).css('background-image', ''+bgImg+' ,linear-gradient( to top, #8D005B 0%, #8D005B 90%, black 50%, black 100% )'); } }); })(jQuery); }); </script> <?php } add_action('wp_footer', 'add_gradient_to_section_bg_image');
February 2, 2023 at 3:34 pm #1396405Thank you very much! I Changed it!
February 2, 2023 at 3:38 pm #1396407Hi Monika,
I’m happy to hear that Guenni007 has helped you :)
@Guenni007 thanks for helping out again :)Best regards,
Nikko -
AuthorPosts
- You must be logged in to reply to this topic.