[Resolved] Hide Background Image When Using Elements

Home Forums Support [Resolved] Hide Background Image When Using Elements

Home Forums Support Hide Background Image When Using Elements

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2338364
    Charles

    https://aireboroughhistoricalsociety.org.uk/

    I want the
    https://aireboroughhistoricalsociety.org.uk/wp-content/uploads/2021/01/ahs-logo-07f.jpg

    graphic to disappear on mobile devices.

    I am using the Elements option and that works well apart from how to stop that displaying on mobiles.

    I can get rid of the text and the contact button with

    And that works find but I cannot figure out where to add the

    “hide-on-mobile” to stop the background image displaying

    Any thoughts welcome.

    I have tried some of the CSS suggestions I have found on Generatepress.

    many thanks

    #2338770
    David
    Staff
    Customer Support

    Hi there,

    so background images are added using CSS, so we need some CSS to remove them.

    1. Add this CSS to your site:

    @media(max-width: 769px) {
        .hide-mobile-bg,
        .hide-mobile-bg:before {
            background-image: none !important;
        }
    }

    This creates a utility class of hide-mobile-bg

    2. Select the Container Block with the background image, and in Advanced > Additional CSS Class(es) add: hide-mobile-bg

    You may need to give you Container Blocks a background color for when the image is removed.

    #2339222
    Charles

    Hi David,

    Many thanks for that answer.
    I suspect you will have guessed that I have asked the wrong question.
    Your answer does remove the background image and I have replaced the gap it leaves with a background colour.

    However, The question I should have asked is, can I apply some code to this element which will prevent it displaying at all and which will close up the gap which removing the picture leaves?

    Am I using the “wrong” code to add the background image and therefore when I want to have a much simpler top text and the hamburger navigation.

    Not using WordPress and Generatepress for website construction I have used different header code and used media queries to change from the desktop to the mobile versions. I realise the “hide-on-desktop works the same way but I cannot figure out how to add that to the element.

    Can the various options hide-on-mobile hide-on-tablet
    And hide-on-desktop
    Be applied the whole element?

    Kind regards

    Charles

    #2339500
    Charles

    This code applied in the elements section has done the job. I used the header option and entire site
    and just wrote this html it could do with a few tweaks but I can easily fix that.

    On the actual site I have then removed the background image on the mobile version and that then displays with a much smaller title and navigation.

    
    
    <div class="hide-on-tablet hide-on-mobile">
        <div>
    	<p style="font-size: 2em; color: white; padding-left: 33%; padding-top: 150px;">Aireborough Historical Society</p>
    	<div>
    		<a href="/contact/"><img src="https://aireboroughhistoricalsociety.org.uk/wp-content/uploads/2021/01/contact.png" /> </a>
    	</div>
        </div>
    </div>
    	
    <div class="hide-on-desktop hide-on-mobile">
        <div>
    	<p style="font-size: 2em; color: yellow; padding-left: 33%; padding-top: 150px;">Aireborough Historical Society</p>
    	<div>
    	    <a href="/contact/"><img src="https://aireboroughhistoricalsociety.org.uk/wp-content/uploads/2021/01/contact.png" /> </a>
    	</div>
        </div>
    </div>
    	
    <div class="hide-on-desktop hide-on-tablet">
        <div>
            <p style="font-size: 2em; color: red; padding-left: 33%; padding-top: 150px;">Aireborough Historical Society</p>
    	<div><a href="/contact/">
    	    <img src="https://aireboroughhistoricalsociety.org.uk/wp-content/uploads/2021/01/contact.png" /> </a>
    	</div>
        </div>
    </div>
    

    I have enclosed the answer in case it might help others. If it is not the “best” solution I would be happy to learn of a better one.

    Sorry, I have not mastered how to add code in the forum. This .jpg shows the code https://aireboroughhistoricalsociety.org.uk/wp-content/uploads/2022/09/code-used.jpgheader code

    #2339805
    David
    Staff
    Customer Support

    Glad to hear you found the answer, and yes that is the way i would go 🙂
    If you’re using the Block Elements ( or just the Block editor ) then you can select a block eg. a Container Block, which will provide you your outer <div>, and in Advanced > Additional CSS Class(es), add any of the hide-on-* classes to get the same result.

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