2013-03-15 266 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