在无响应的网站中进行DIV响应。

时间:2016-01-07 15:03:51

标签: html css

我的非响应式网站中有一个div,其中包含一个120x600像素的广告。我想让div浮动始终位于屏幕右侧。对于台式机或大型设备,它是可以的但是当在较小的设备中时,因为站点没有响应,所以当站点加载时,div变得非常小。如果该站点响应,则在宽度约为400px的设备中,它将覆盖屏幕的几乎所有部分。我需要在我的无响应网站中这样做。这是为了提高广告点击率。一个示例div是 -

<div id="float_rightad" style="position:fixed; top:15%; right:0;width: 160px; height:600px;  z-index:5000;">
    <div style="position:absolute; left:-5px; margin-top:0px; z-index:15;">
        <a href="Javascript:void(0);" onclick="document.getElementById('float_rightad').style.display='none'"><img src="http://secretdiarybd.com/wp-content/uploads/2015/05/close.gif.png" alt="close" height="20"></img>
        </a>
    </div>
    <div>
        <script data-cfasync="false" type="text/javascript" src="//www.sparkadsmedia.com/adscript/120x600_english.js"></script>
    </div>
</div>

我怎样才能在我的网站上这样做?

1 个答案:

答案 0 :(得分:1)

你可以通过在类似下面的样式块中添加额外的CSS3语句来实现它,并使用广告的相对宽度(%)(尽可能):

<style type="text/css">
    @media screen and (orientation: landscape ) and (max-width:400px ) {#float_rightad { YOUR STYLE PERTINENT TO SMALL SCREEN}}
    @media screen and (orientation: portrait ) and (max-width:400px )  {#float_rightad { YOUR STYLE PERTINENT TO SMALL SCREEN}}
</style>

如果你的add包含 img 元素,那么你可以指定容器 div 的图像宽度相对(%);否则,请考虑使用 iframe 元素。 希望这可能有所帮助。 最好的问候,

相关问题