2013-04-03 74 views
0

這就是我想要的chicklet框的樣子:![] 1 由於某種原因,我無法使用負邊距讓twitter圖像到達中心框。我的親子關係有什麼問題嗎?負面的上邊距不會對兒童圖像起作用

我的CSS是在外部表,但在這裏它是:

<style type="text/css"> 

#chicklet_container { 
    margin:20px auto 0px auto; 
    width:540px; 
    height:215px; 
} 

#chicklet_box { 
    margin:0px 0px 10px 0px; 
    width:190px; 
    height:160px; 
    border-style:solid; 
    border-width:33px 5px 5px 5px; 
    border-color:#45BA88; 
    position:relative; 
} 

#chicklet_box2 { 
    margin:-30px 0px 10px 0px; 
    width:190px; 
    height:160px; 
    border-style:solid; 
    border-width:0px 0px 30px 0px; 
    border-color:#3f4040; 
} 

#chicklet_text { 
    text-align:center; 
    margin:-196px 0px 0px 0px; 
    color:#FFF; 
    width:190px; 
    font-family:"Verdana, Geneva, sans-serif"; 
    font-size:27px; 
    line-height:20px; 
} 

#chicklet_text2 { 
    text-align:center; 
    margin:139px 0px 0px 0px; 
    color:#FFF; 
    width:190px; 
    font-family:"Proxima, Nova, Ultralight"; 
    font-size:26px; 
    line-height:20px; 
} 

#chicklet_box img { 
    margin:-250px 0px auto 5px; 
} 
</style> 

下面是HTML:

<div id="chicklet_container"> 
    <div id="chicklet_box"> 
     <div id="chicklet_box2"> 
     </div> 
      <div id="chicklet_text">Follow Me</div> 
      <div id="chicklet_text2">@soandsoandso</div> 
      <img src="images/twitter.jpg" alt=""> 
    </div> 
</div> 
+0

你能提供一個你正在使用的圖像的鏈接,或者至少告訴我們這個大小,以便我們可以測試它嗎? – metadept 2013-04-03 19:33:46

回答

0

你爲什麼要使用這麼多的保證金對準Twitter的鳥形象或文本。儘可能使用低邊距。相反,請嘗試使用該圖像position:absolute;和頂部左側屬性。它會更乾淨。但有一點要記住,如果你使用元素的絕對位置,檢查它的外部元素或父元素是否定位,如果不是,那麼事情可能會變得更糟,並且該子元素可能會去其他地方。