2013-01-02 34 views

回答

8

jsFiddle DEMO

鼠标悬停的元素,使他们大可以以多种方式来完成,它的使用框架取决于你的布局要求和。

因为那些箱子似乎是DIV与CSS3盒子阴影属性,你可以用做这样的事情在纯CSS:悬停

HTML:

<div class="box">1</div> 
<div class="box">2</div> 
<div class="box">3</div> 

CSS:

body { 
    background-color: black; 
} 

.box { 
    background-color: grey; 
    width: 200px; 
    height: 400px; 
    float: left; 
    border: 6px solid red; 
    margin: 10px; 
} 

.box:hover{ 
    width: 250px; 
    /* This is 52px total. 1/2 of that is for top and the other half is for bottom. */ 
    height: 452px; 
    /* Below we are not using -26px for margin-top because .box has 6px border and 10px margin. */ 
    /* That 16px is then divide by 2 since it's for both top and bottom, or 8px per side. */ 
    /* Having said that, 26px - 8px is 18px. We need negative value to position it correctly. */ 
    margin-top: -18px; 
-moz-box-shadow: 0 0 50px red; 
-webkit-box-shadow: 0 0 50px red; 
box-shadow:   0 0 50px red;  
} 

编辑2:

Revised jsFiddle DEMO

enter image description here

+1

非常感谢您的帮助。 – user1943906

+0

如何将图像与链接放在其中一个框中? – user1943906

+0

这取决于您的HTML和布局要求。 [**范例**](http://jsfiddle.net/Hz97u/8/)。请注意classname'image'需要一个框架,比如'JavaScript'或'jQuery',这样你就可以使用它来构建一个可以遵循的链接。 – arttronics

4

你可以做到这一点使用 “改造:规模(X,Y)” 按钮放大你的元素。

E.g.

div:hover{ 
transform: scale(1.5, 1.25); 
-moz-transform: scale(1.5, 1.25); 
-ms-transform: scale(1.5, 1.25); 
-webkit-transform: scale(1.5, 1.25); 
-o-transform: scale(1.5, 1.25); 
} 

将使您的div在x轴上缩放1.5倍,并在y轴上保持1.25倍。

要添加阴影 -

div:hover{ 
-moz-box-shadow: 5px 5px 5px #888; 
-webkit-box-shadow: 5px 5px 5px #888; 
box-shadow: 5px 5px 5px #888; 
} 
相关问题