【发布时间】:2011-12-22 21:05:35
【问题描述】:
如果我的问题很愚蠢,请原谅我,但我不是网络程序员,过去 2 个小时我一直在试图解决这个问题。
所以,我在我的网站上使用 Weebly,并且有一个“内容”区域可以放置元素。然后在“内容”区域的左右两边,我要放置广告。
我已经弄清楚如何使用绝对定位来做到这一点,它在计算机的浏览器上看起来不错,但在移动设备上(无论使用什么用户代理),google adsense 广告都会覆盖我的内容区域。
这是我想要的样子:
http://testing.jakaar.net/(这个网站已经不存在了。
编辑:http://android.jakaar.net/index.html(这是我的网站,现在可以使用,请参阅下面的问题答案)。
但是,这在手机上是行不通的。广告仍然显示,它们只是叠加。
编辑:它现在有效,请参阅下面的答案。
我尝试在我的 css 中使用 position:relative 将广告定位在左侧和右侧,但它们要么在我的内容区域上方或下方,因此它会将所有内容向上或向下推。
这是我认为相关的 CSS:
body {
background: url(bodybg.jpg) top repeat-x;
background-color:#efefef;
font-family: arial, sans-serif;
font-size:12px;
color:#666666;
margin:0;
padding:0;
}
#content{
margin-left:auto;
margin-right:auto;
width: 898px;
background: #fff;
min-height: 500px;
_height: 500px;
padding: 32px;
}
那么对于 HTML:
<head>
<title>{title}</title>
<style type="text/css">
.right
{
position:absolute;
right:0px;
padding-right:80px;
padding-left:80px;
margin-top:180px;
}
.left
{
position:absolute;
left:0px;
padding-right:80px;
padding-left:80px;
margin-top:180px;
}
</style>
<div id="wrapper">
<div id="header">
<div id="headerleft">{logo max-height="60"}</div>
<div id="navigation">{menu}</div>
</div>
<div class="right">
//adsense add that goes on the right
</div>
<div class="left">
//adsense add that goes on the left
</div>
<div id="content">
{content}
</div>
<div id="footer">{footer}</div>
</div>
我也尝试过使用float:left 和float:right,但它的行为与绝对定位相同。
非常感谢任何帮助。
【问题讨论】:
标签: css position overlay alignment absolute