-
David
I would be more inclined to use Elements, simply for the ease of maintenance.
-
ChristPulse
Thank you
-
David
You’re welcome
-
ChristPulse
I created elements (Block hooks) for Google Ads. Some are aligned well, some not. For example, this one:
I don’t know how to center it as an element because nothing I have tried works.
-
We do not have control over the ads, it comes with lots of CSS, and it might not be good CSS.
Give this CSS a try, if it doesn’t work, you will need to check with the ads provider:
.adsbygoogle { max-width: 100%; overflow-x: hidden; }
-
ChristPulse
Can I set this in the block settings (container) or add the code as a snippet?
Also, the problem exists only on mobile -
There is no place to add CSS code in block level, add it to customizer > additional CSS:
@media(max-width: 768px) { .adsbygoogle { max-width: 100%; overflow-x: hidden; } }
-
ChristPulse
Hmm… no, it’s not working. Some ads are still aligned too far to the left. This is how it looks on the homepage. Is there no other solution?
-
The container block that the advert sits inside of, select that , and in the block settings set the alignment to Wide Width. This will allow the container to overcome the container padding. And then when the advert loads it should be able to fill the viewport width and be centred.
-
ChristPulse
Are you talking about the first container or the parent container of HTML code?
-
David
The parent container thats wrapping the Advert HTML Code.
-
ChristPulse
Not working.
-
Can you take a screenshot of the container alignment?
-
ChristPulse
May I ask you to go inside wp-admin and check it out? It would be more efficient. Private information updated
-
David
I made a modification to one of the mobile ads to simplify things.
See here:https://app.screencast.com/GXOJoiqcVZ4Cl
The:
Google Ad #2 (mobile)
is now a plain Container block with no Layout, Spacing or Sizing.
This will make the Container fill the width of the viewport.
The only block setting is the Text Align Center. option.
This will center and “block” HTML as well as text.
The Inner Container block was removed.This will make the Container fill the width of the view port and centre the advert inside it.
See if that works for you, if it does you can apply the same layout to the other mobile ad containers -
ChristPulse
I did it as you said. Removed inner container and center the parent container. These are screenshots of the Google ad for the sidebar on mobile.
- You must be logged in to reply to this topic.