2012-05-17 41 views
0

我做了一個精靈般的技術懸停和新/舊的瀏覽器

<a href="#"> 
<img width="240" height="160" src="240x160.jpg" class="…wp-post-image" alt="287" title="287" /> 
</a> 


a{ 
    display:block; 
    overflow: hidden; 
    width:120px; 
    height: 160px; 
} 

a:hover img{ 
    margin-left: -120px; 
} 

它的工作,但它更好像這樣(在XHTML 1 STRIC或HTML5)翻轉效果?

a img:hover{ 
    margin-left: -120px; 
} 

回答

0

最好使用background-image屬性而不是實際圖像來避免瀏覽器問題。

a{ 
    display:block; 
    overflow:hidden; 
    width:120px; 
    height:160px; 
    background:url(240x160.jpg) no-repeat 0 0; 
} 
a:hover{ 
    background-position:-120px 0; 
} 
+0

同意你,但它是在一個CMS和內聯風格不是很好。我不想要ie6支持(這是一個效果)。 –

相關問題