2010-08-03 52 views
1

我有一個圖像的無序列表,顯示內嵌和浮動相鄰。在Firefox和Chrome瀏覽器中一切都很好,但在Internet Explorer中,最後一張圖片會垂直下推一點。任何想法爲什麼會發生?鏈接是在這裏:Internet Explorer CSS Float最後的圖像偏移量

http://www.mercedesberk.org/chic-and-new/manhattan-house

這裏是基本的代碼:

<div id="fatured_properties"> 
<h4> Also in the Neighborhood </h4> 
    <ul> 
     <li> 
      <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> 
       <img src="<?php bloginfo('template_directory'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, 'image', $single = true); ?>&amp;h=135&amp;w=180&amp;zc=1" alt="<?php the_title(); ?>" /> 
      </a> 
      <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> 
       <span><?php the_title(); ?></span> 
      </a> 
     </li> 
     ... etc .... 
    </ul> 
</div> 

和CSS:

#fatured_properties { 
    overflow: auto; 
    text-align: center; 
    width: 100%; 
} 

#fatured_properties h3 { 
    text-transform: uppercase; 
    color: #f60; 
    font-size: 13px; 
    padding-bottom: 10px; 
    margin: 0 auto; 
    display: block; 
    width: auto; 
} 

#fatured_properties ul{ 
    display: inline; 
} 

#fatured_properties ul li{ 
    margin: 0 5px; 
    float: left; 
} 

.hamptons_guide #fatured_properties ul li{ 
    margin: 0 14px; 
} 

#fatured_properties ul li img{ 
    display: block; 
    clear: both; 
} 

#fatured_properties ul li span { 
    font: bold 13px "Calibri", Verdana, Helvetica, sans-serif; 
    letter-spacing: 1px; 
    width: 195px; 
    display: block; 
    text-align: left; 
} 
+0

哪個版本的IE?我看到內容區域的浮動下降,因爲'chic_left'超出了指定的寬度,您可以用'overflow-x:hidden;'來反作用。我正在使用IE6。 – 2010-08-03 00:25:36

回答

3

您移除UL默認填充/利潤率和李應該做的伎倆:

#fatured_properties ul{ 
    margin: 0; 
    padding: 0; 
    display: inline; 
} 

#fatured_properties ul li{ 
    padding: 0; 
    margin: 0 5px; 
    float: left; 
} 

所有瀏覽器的填充和邊距默認值都略有不同,所以最好將它們全部設置爲零,然後根據需要重新添加它們。

0

它看起來像ul元素的邊緣導致IE8中的問題。嘗試添加margin: 0;該元素,像這樣:

#fatured_properties ul{ 
    display: inline; 
    margin: 0; 
} 

編輯:是否有你已經宣佈,UL爲內聯一個特別的原因? UL通常作爲塊級元素運行,並且圖像仍然像預期的那樣相互浮動。