How to position AdSense on site with CSS position: absolute

Go To StackoverFlow.com

3

I have an AdSense account, and simply copy/pasted a block of Javascript to include ads on my site. However, since I did not put any HTML in place, the Js is generating an iframe and an ins element which the ads are appearing within.

I want to move those ads to the left of my content, where I have made space for them. I've tried adding CSS like "ins, iframe { position: absolute; left: 0; top: 0; }" but it seems to be overwritten.

So my question is: how can I force the AdSense ads to appear where I want them to? Preferably with CSS.

2012-04-04 17:15
by Bing


4

You do it the same way you use CSS to control anything else: put it in a div, give it a class (or id), and format the parent object.

Are you already using CSS? If so, just add a new one something like this in main.css:

#google{
    position:absolute;
    right:0px;
    width:160px;
    top:120px;
    border-left: 1px solid black;
}

Then in your page, where appropriate, add the following around Google's JavaScript:

<div id="google">
    <--! code here -->
</div>
2012-04-04 17:19
by warren
Ugh, I didn't think it would insert its HTML within the location I dropped the Javascript, so I was dropping it in the head, making it impossible to style. Thank you - Bing 2012-04-04 17:25
missing the character # in cs - Davide Palmieri 2013-10-15 13:31
Ads