开发者

Newbie CSS/HTML: How to add ad in a div container to the side of the page?

I got a centered website with a fixed width. Now, I want to add an ad banner开发者_Python百科 of fixed 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 the side. I dont know why. Can someone help me please with my CSS id?

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

EDIT: Image - (link removed as broken)

This is what I want. I got the orange one. I don't want to set the banner position to the right browser border. It should be near the wrapper class.


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.


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


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.


Did you try using float: right property ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜