homepage Welcome to WebmasterWorld Guest from 54.205.242.179
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: DrDoc

CSS Forum

    
CSS Positioning For a Centered Website
PaulPA




msg:3793434
 12:10 am on Nov 25, 2008 (gmt 0)

I am working on trying to set up my CSS to enable the first instance in the source code for Adsense to be directed to the top click through location on my site. This is not the top ad location on the page (it is a little further down) so I need to position it using CSS. However, I can't seem to get this to work right. My problem seems to be with the fact that my site has a width of 1000px and is centered on the page.

While I can position the ads properly within one screen resolution (e.g., 1280) it will not maintain its position when the resolution is changed (e.g, 1024). I've used what I know about CSS positioning (e.g., absolute vs. relative, em instead of px) but without luck.

Is this possible to do without having to create conditionals based on screen resolution (e.g. if screen resolution is 1024 do this)?

Any guidance you can offer is greatly appreciated.

 

BadBoyMcCoy




msg:3793625
 7:43 am on Nov 25, 2008 (gmt 0)

If you are using some kind of wrapper div to center everything one work around would be

div#wrapper {
width:1000px;
margin:0 auto;
padding-top:200px; /*Change this according to the height of your adsense div, its purpose is to push down the rest of the page content to make room for adsense div*/
position:relative; /*needs to be relative so that absolutly positioned elements are placed correctly within it*/
}
div#adsense {
width:1000px;
height:200px;/*Change this according to the height of your adsense div*/
position:absolute;
top:0px; left:0px;
}

I think you would have to use javascript if you wanted to work out a site visitors screen size

I'm not sure if that helps, the above code is assuming you want the ad right at the top of the page

If you wanted it on the left say, use the same basic idea

div#wrapper {
width:800px;/*1000px - 200px padding*/
margin:0 auto;
padding-left:200px;
position:relative;
}

div#adsense {
width:200px;/*same as padding again*/
position:absolute;
top:0px; left:0px;
}

OK I hope that helps,

Or have I completly misunderstood the question?

PaulPA




msg:3793769
 12:27 pm on Nov 25, 2008 (gmt 0)

Thanks BadBoyMcCoy! You clued me in on something I was doing wrong in my coding and now all seems to work fine. Greatly appreciated.

BadBoyMcCoy




msg:3793789
 12:56 pm on Nov 25, 2008 (gmt 0)

Your welcome

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved