代码之家  ›  专栏  ›  技术社区  ›  Swift

Internet Explorer CSS浮动上次图像偏移量

  •  1
  • Swift  · 技术社区  · 15 年前

    我有一个无序的图像列表,这些图像显示在一行中,并且彼此相邻浮动。在火狐和Chrome中,一切看起来都很好,但是在Internet Explorer中,最后一张图片垂直向下推了一点。知道为什么会这样吗?链接在这里:

    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; 
    }
    
    2 回复  |  直到 15 年前
        1
  •  3
  •   Pat    15 年前

    从ul和li中删除默认的填充/页边距应该可以做到:

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

    所有浏览器的填充和边距默认值都略有不同,因此最好将它们全部设置为零,然后根据需要重新添加。

        2
  •  0
  •   peterjmag    15 年前

    看起来ul元素的裕度导致了ie8中的问题。尝试添加 margin: 0; 对那个元素,就像这样:

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

    编辑: 您是否有特殊原因将ul声明为inline?ul通常表现为块级元素,图像仍会按预期相互浮动。