How To Place Adsense On A Site With CSS Position: Absolute

I have an Adsense account and just copy / paste the Javascript block to enable ads on my site. However, since I didn't put the HTML in place, the Js generates an iframe and an ins element where the ads appear.

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

So my question is, how do I get my Adsense ads to appear where I want? Preferably with CSS.

+3


source to share


1 answer


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.

Are you already using CSS? If so, just add something like this to main.css

:

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

      



Then, on your page, where appropriate, add the following to Google JavaScript:

<div id="google">
    <--! code here -->
</div>

      

+4


source







All Articles