Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #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%
    )

    #1396117

    Hi 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,
    Nikko

    #1396152

    Hey 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
    Monika

    #1396177

    Hi 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,
    Nikko

    #1396288

    Now 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?

    #1396290

    https://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 last

    #1396291

    Thank 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?

    #1396323

    Hi 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,
    Nikko

    #1396337

    But 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?

    #1396340

    if 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-gradient

    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('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 element

    see: https://enfold.webers-webdesign.de/two-bg-images/

    #1396371

    Or – if you like to have that “gradient” generated from background-color of the section to black :
    https://enfold.webers-webdesign.de/test5/

    #1396382

    Thank 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
    Monika

    #1396383

    you 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 front

    if 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
     */
    #1396384

    THAT WORKED!!

    Nice! Im so happy
    Thank you very much for this amazing support here :))

    #1396385

    but 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');
    #1396405

    Thank you very much! I Changed it!

    #1396407

    Hi Monika,

    I’m happy to hear that Guenni007 has helped you :)


    @Guenni007
    thanks for helping out again :)

    Best regards,
    Nikko

Viewing 17 posts - 1 through 17 (of 17 total)
  • You must be logged in to reply to this topic.