2014-03-02 160 views
0

我將Google AdSense的廣告添加到我的頁面底部。 Adsense在我的div中創建一個iframe,並將其廣告放入其中。 (我更改了iframe的src並添加了1px邊框來演示小提琴)我將這個用於智能手機和平板電腦用戶。在屏幕底部放置div

小提琴:http://jsfiddle.net/mavent/Hpm6L/12/

<div id="mydiv" class="row my_center hidden-print" 
    style="position:fixed;bottom:0;left:0;right:0;/* height:50px; */ 
      border: 1px solid red;"> 
    <iframe id="aaaa" name="aaaa" width="320" height="50" frameborder="0" 
    src="http://www.wsj.com" marginwidth="0" marginheight="0" vspace="0" 
    hspace="0" allowtransparency="true" scrolling="no"> 
    </iframe> 
</div> 

.my_center { 
    text-align:center; 
} 

當我創建這個,mydiv自動具有55像素的高度。在這種情況下,廣告下方會出現5px的空白。如果我設置height:50px;問題可以解決,但它會產生另一個問題(我必須檢查用戶是否具有大於768px的寬度,併爲他/她的表格版本化谷歌廣告等。)

那麼爲什麼會出現這個「5px」?我看不到任何邊界,底部邊緣等?
我該如何將這個div粘貼到底部?

+0

您的CSS一個錯字。在你的身高規格之前需要分號。 – box86rowh

回答

2

試試這個小提琴。 設置在你的樣式中:line-height:0;

http://jsfiddle.net/Hpm6L/14/

HTML:

<div class="row my_center hidden-print" style="position:fixed;bottom:0;left:0;right:0;11height:50px;border: 1px solid red;line-height:0;"> 
      <iframe id="aaaa" name="aaaa" width="320" height="50" frameborder="0" src="http://www.wsj.com" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no"></iframe></div> 

CSS:

.my_center { 
    text-align:center; 
}