[Resolved] Custom margins for mobile

Home Forums Support [Resolved] Custom margins for mobile

Home Forums Support Custom margins for mobile

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #81685
    George

    Is there any way to use different element margins when on mobile? My margins are large for reading on large screens, but they end up being way to big for mobile.

    As usual, thank you!

    #81768
    Tom
    Lead Developer
    Lead Developer

    Absolutely – you’ll need to use some custom CSS targeted for mobile like this:

    @media screen and (max-width: 768px) {
          /* mobile CSS in here */
    }
    #81906
    George

    Excellent! It worked great (after some experimentation looking for which elements I needed to target, and discovering there was extra spacing in the footer). Here’s my code for anybody else that might need it. Tom, I’m sure you have some feedback on it as well, just in case I targeted anything unnecessary. FYI, all of the feedback you have given me is easily worth the price I paid for GP premium πŸ™‚

    @media screen and (max-width: 768px) {
    	.separate-containers .inside-article, .separate-containers .comments-area, 
    					.separate-containers .page-header, .separate-containers .paging-navigation, 
    					.one-container .site-content, .separate-containers .widget.inner-padding {
    		padding-left: 25px;
    		padding-right: 25px;
    	}
    	
    	.separate-containers .site.footer-widgets {
    		padding-left: 0;
    	}
    }
    #81969
    Tom
    Lead Developer
    Lead Developer

    Looks good to me! Good job πŸ™‚

    #81972
    George

    Thank you. Hopefully the code will be useful for somebody else who is in the same boat as me.

    #225708
    Tully

    Hi Tom

    I am trying to do a similar thing – just want the right and left margins to be smaller than they are on mobile. I have tried the above CSS but nothing appears to change? It does work on one of my generate press websites, http://www.bendigodogtraining.com.au, but not on the other: http://www.campaspeworkingdogs.com/wordpress. Thanks Tom

    #225839
    Tom
    Lead Developer
    Lead Developer

    The site where it’s not working is password protected so I can’t check.

    #226264
    Tom
    Lead Developer
    Lead Developer

    Ah, you’re using Sections, so your CSS would be:

    @media (max-width: 768px) {
        .generate-sections-inside-container {
            padding-left: 25px;
            padding-right: 25px;
        }
    }
    #226311
    Tully

    Hi Tom,

    On its own that didn’t work, but when I inserted the .generate-sections-inside-container into the CSS in the above code from George it worked. As always, thanks for the amazing support for GeneratePress! Can I donate?

    #226391
    Tom
    Lead Developer
    Lead Developer

    No problem!

    That would be amazing! There’s an ongoing development link in my signature below πŸ™‚

    Thanks!

    #226489
    Tully

    Just sent $100 your way. Thanks for all your help Tom and the great theme etc!

    #226524
    Tom
    Lead Developer
    Lead Developer

    That’s amazing, thank you so much! Incredibly generous πŸ™‚

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