2013-03-15 265 views
0

我想要獲得一個背景圖像來顯示鼠標懸停在三個圖像中的任何一個。這裏是一個jsFiddle:http://jsfiddle.net/cvh2013/gefKT/,誰能告訴我我做錯了嗎?此時,當您懸停三個圓形圖像中的任何一個時,背景圖像都不會顯示。CSS:背景圖像問題

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta charset="UTF-8" /> 
<title>SVG Included with <object> tag</title> 

<style> 
.center { 
text-align: center; 
} 

#images:hover { 
background-image: url(http://ubuntuone.com/1SRrDB8i8cBtpm3Smxaz5r); 
background-repeat: no-repeat; 
} 
</style> 
</head> 

<body> 
<table style="width: 100%"> 
    <tr> 
     <div id="images"> 
      <td class="center"><object type="image/svg+xml" 
        data="http://ubuntuone.com/5b5ZUS86nHAffWiOirDwFr"> 
        <img src="http://ubuntuone.com/12qOaTGCZYzQtqFJpaGbPV" alt="" /> 
       </object></td> 
      <td class="center"><object type="image/svg+xml" 
        data="http://ubuntuone.com/7Ur09JXlGVvF2GhXFbLXlx"> 
        <img src="http://ubuntuone.com/54AaqhQUU8npACF2vXzKFp" alt="" /> 
       </object></td> 
      <td class="center"><object type="image/svg+xml" 
        data="http://ubuntuone.com/6tkHm9c2r1eH9PMB9Nr3Ux"> 
        <img src="http://ubuntuone.com/4CXw05d1dsSf9VhAIPNZf6" alt="" /> 
       </object></td> 
     </div> 
    </tr> 
</table> 

</body> 
</html> 
+0

你不需要告訴它的圖像類型? – 2013-03-15 20:58:19

+0

@JeffHawthorne文件擴展名僅僅適用於簡單的文件系統(和人類),如果網絡服務器使用正確的MIME類型進行響應,那麼瀏覽器將做正確的事情 – 2013-03-15 21:02:00

+0

看看這個小提琴http://jsfiddle.net/gefKT/ 10/ – rzymek 2013-03-15 21:03:48

回答

0

#images div包含沒什麼因此沒有尺寸,因此永遠不能上空盤旋。你需要把你的三張圖片放在這個div裏面。

+0

謝謝你,工作!我在每個 2013-03-15 21:36:50

2

如果我是你如下我會改變CSS:

<style> 
.center {text-align:center;} 
.boxy:hover {box-shadow:0 0 5px #000; border-radius:50%;} 
</style> 

而且.boxy類添加到您已聲明的對象。 Border Radius比使用圖像更清潔(需要再加載一個資源)。如果您希望在IE8及更低版本上工作,您可以使用您想要的實際圖像方法。

小提琴:http://jsfiddle.net/gefKT/9/

+0

周圍放一個div謝謝Marco,知道的非常有用。 – 2013-03-15 21:37:12