2011-12-11 20 views
0

我想把一個絕對定位的圖像內部的TD。以下代碼在FF 3.6中的圖像上方創建了不需要的間隙,並使圖像在IE 7中消失。我在表代碼之前包含了相關的外部樣式表元素。如何將絕對定位的img放入​​?

#leftColTopTdImg 
{ 
padding:0px; 
margin:0px; 
position:relative; 
} 
#navLinksTD 
{ 
position:relative; 
padding:0px; 
margin:0px; 
} 
#navLinksBoxDiv 
{ 
position:relative; 
width:100%; 
height:100%; 

padding:0px; 
margin:0px; 
} 
#navLinksInBox 
{ 
position:relative; 
} 
#navLinksBg 
{ 
position:absolute; 
width:100%; 
height:100%; 
} 

    <table width="222px" cellspacing="0px" cellpadding="0px" border="0px"> 
    <tbody> 
     <tr> 
      <td id="leftColTopTdImg"><img width="222px" height="77px" alt="" src="../leftcol_top.jpg" /></td> 
     </tr> 
     <tr> 
      <td id="navLinksTD"> 
       <div id="navLinksBoxDiv"> 
        <img id="navLinksBg" src="../menu_combined_2r.jpg" alt="The background for the navigation link box. It has a vertical gradient going from light to dark and then dark to light blude" /> 
        <ul id="navLinksInBox"> 
         <li> 
          <a href="#">Driving While Intoxicated</a> 
         </li> 
         <li> 
          <a href="#">Sex Crimes</a> 
         </li> 
         <li> 
          <a href="#">2nd Driving While Intoxicated</a> 
         </li> 
         <li> 
          <a href="#">2nd Sex Crimes</a> 
         </li> 
        </ul> 
       <!--End of navLinksBoxDiv-->                
       </div> 
       <img id="menuBottom" src="../menu_bottomedge.jpg" alt="The bottom of the menu" /> 
      <!--End of navLinksTD--> 
      </td> 
     </tr> 
    </tbody> 
</table> 

我對定位TD內的絕對格但同樣的伎倆,似乎並沒有在這種情況下工作了很多閱讀。我如何將絕對定位的img放在td中?謝謝。

回答

0

它很難看到什麼是錯的,沒有看到的結果,但幾件事情我已經注意到直線距離:

你還沒有爲您的絕對定位圖像的位置(即頂部:0;左:0;)...這可能是你的消失圖像的原因

你也沒有指定填充&邊距爲0爲圖像本身。

如果是表本身引起的問題,你也可以嘗試: table {border-collapse:collapse;} 確保邊界被摺疊並且不留空隙。