tags:

views:

453

answers:

4

Hello, i got an centered website with a fixed width. Now i want to add an ad banner of fix width/height to the right side of the page. There is a wrapper div of width 700px. But i can't get my banner on my side. I dont know why. Can someone help me please with my css id? i got:

<div class="wrapper">
   <div class="head"></div>
   <div class="content"></div>
</div> //wrapper

EDIT: KLICK ME FOR AN IMAGE

This is what i want. I got the orange one. I dont want to set the banner position to the right browser border. It shout be near thw wrapper class.

A: 

Did you try using float: right property ?

JonH
The problem is that "float: right" put the banner near the scrollbar, but i want it this way:http://yfrog.com/6lcsseg
SurfingCat
+2  A: 

If you want the banner to be inside the wrapper:

HTML

<div class="wrapper">
  <div class="banner"></div>
  <div class="head"></div>
  <div class="content"></div>
</div>

CSS

div.banner { float: right; width: 100px; height: 400px; }

If you want it outside the wrapper:

HTML

<div class="banner"></div>
<div class="wrapper">
  <div class="head"></div>
  <div class="content"></div>
</div>

CSS

div.banner { float: right; width: 100px; height: 400px; }

You can also check out this site for a bunch of different CSS/HTML layouts:

http://layouts.ironmyers.com/

Following Edit...

I think this question at Stack Overflow has what you want.

sohum
The problem is, i want to center the main part of the page / 2. And with this solution (in wrapper) i get the center of the page (mainpart+ad)/2. http://yfrog.com/6lcsserrorgThe center is not longer in the middle of all, u know? If i put the banner outside the wrapper, it floats to the right side of the screen but not near the main content...
SurfingCat
So you want the page centered in the middle and the ad container adjacent to it? Let me know if that's what you want. I haven't done something like that before, so I'll have to prototype it before I get you a solution.
sohum
I think I may have found another question that solved this problem. Check my original solution. Please let me know if this is not what you want and I'll play around with it when I get home.
sohum
+1  A: 

Go to this site and you will find the answer to your question and all the your future questions (judging by your question) http://www.w3schools.com/css/css_float.asp

halocursed
+1  A: 

put the give the ad-div in the wrapper-div, give it an absolute position and move it to the right. Make sure to give the wrapper-div a relative position.

html

<div id="wrapper">
<div id="ad">ad</div>
</div>

css

#wrapper{
position: relative;
}

#ad {
position: absolute;
right: -140px;
}

The wrapper div will still be centered, the ad-div will 'hang' next to it.

Tazzle