1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 Centering Adsense

Discussion in 'Styling and Customization Questions' started by Mackeral_Fillet, Feb 11, 2015.

  1. Mackeral_Fillet

    Mackeral_Fillet Active Member

    Hiya,

    I know this is pretty basic but I can't work out how to centre my Adsense - see after the post 4 its left aligned:

    http://ducatiforum.co.uk/forum/threads/she-lands-today.30436/

    Anyone help?

    My current code is:
    Code:
    <xen:hook name="ad_message_below" />
    
    <xen:hook name="ad_header" />
    <div class="float_center" style="margin:10px 10px 10px 0px">
    
    <style type="text/css">
    .overtaking-top-dynamic {
    width: 300px;
    height: 50px;
    }
    
    @media(min-width: 319px) {
        .overtaking-top-dynamic {
        width: 250px;
        height: 60px;
        }
    
    @media(min-width: 484px) {
        .overtaking-top-dynamic {
        width: 468px;
        height: 60px;
        }
    
    @media(min-width: 655px) {
        .overtaking-top-dynamic {
        width: 400px;
        height: 60px;
        }
    
      @media(min-width: 650px) {
        .overtaking-top-dynamic {
        width: 500px;
        height: 90px;
        }
    
        @media(min-width: 900px) {
        .overtaking-top-dynamic {
        width: 665px;
        height: 90px;
        }
    
       
        @media(min-width: 950px) {
        .overtaking-top-dynamic {
        width: 728px;
        height: 90px;
        }
    
    
    }
    </style>
    
    <xen:if is="!{xen:helper ismemberof, $visitor, 9}">
    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 3">
    
    
    <style>
    .ducati-forum-homepage-main { width: 320px; height: 50px; }
    @media(min-width: 500px) { .ducati-forum-homepage-main { width: 468px; height: 60px; } }
    @media(min-width: 800px) { .ducati-forum-homepage-main { width: 728px; height: 90px; } }
    </style>
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- Ducati Forum Homepage main -->
    <ins class="adsbygoogle ducati-forum-homepage-main"
         style="display:inline-block"
         data-ad-client="ca-pub-"
         data-ad-slot="8034417992"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script></div>
    
    
    </xen:if>
    </xen:if> 
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Add text-align:center to the div.

    You have a lot of superfluous code there and in the wrong order so you may want to redo the template (I can see you've copied it from the resource example).
     
    Mackeral_Fillet likes this.
  3. Mackeral_Fillet

    Mackeral_Fillet Active Member

    Yes, I did. Could you be specific in what you'd recommend? I am not too sure what to add/remove.
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Mackeral_Fillet likes this.
  5. Mackeral_Fillet

    Mackeral_Fillet Active Member

    Thank you Brogan. I will take another look and study to work out what I need to do.

    Can you help with one more thing?

    What conditional do I need to add to get the adsense to display after the 3rd post, and x'th post?

    Code:
     <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 3">
     

Share This Page