Issue centering ad units

Hello, I’m having an issue getting 3rd party ad code to properly center on my pages. To explain, please visit https://www.bourbonbanter.com/banter/wild-turkey-the-best-private-barrel-pick-ever/#.Wk6aMlQ-fgH.

On this page, if you scroll down to where you can subscribe to our mailing list, there will be an ad unit. It is aligning left. No matter what settings I change it will not remain centered.

I’ve tried centering at the row level and the section level in the Pro editor. My ad partner had me add code to the ad block itself and still, it won’t work. Sometimes it will center but then it goes back to left aligned.

I’m using a Widget block to pull in a widget that has only the ad block code in it.

I see website all over the web with perfectly aligned ads and it’s killing me not to be able to fix it.

Help please!

Hello @patrickg,

Thanks for asking. :slight_smile:

If you are looking to reduce the vertical spacing then you can do that by changing the padding of section. However, if you are looking to vertically center align Google adsense ads then unfortunately that’s not possible as those ads a loding on a iframe and it’s difficult to control alignment inside iframe.

Thanks.

Appreciate the feedback. I’m not using Adsense but I can speak to my ad network folks. However, I can’t the link you sent to display anything. Would you mind sending ti [email protected]? Thanks.

Hello There,

Thanks for updating us in! Regretfully we do not send emails to our users from our staffs. We only communicate through the community support forum.

Meanwhile, you may use this code and add this in the X > Launch > Theme Options > Global CSS (http://prntscr.com/evui3r) or in the customizer, Appearance > Customize > Custom > Edit GLOBAL CSS

body .defy_target {
    text-align: center;
}

body .defy_target div {
    max-width: 728px;
    margin: 0 auto;
}

We would loved to know if this has work for you. Thank you.

It looks like it works for the ad units I was talking about. Unfortunately, it also centers the ad units in my sidebar (see attached). I don’t need those modified at all. Is there a way to modify the code so it only affects the ones I want?

Hello There,

If you do not want to include the sidebar, you may use this code instead:

body .x-main .defy_target {
    text-align: center;
}

body .x-main .defy_target div {
    max-width: 728px;
    margin: 0 auto;
}

Please let us know how it goes.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.