你好,這是很簡單的在這裏爲基礎的一些代碼:
CSS:
.image{
width:200px;
height:200px;
background:red;
margin:0 auto;
}
.transition{
-webkit-transition: all .2s linear;
-o-transition: all .2s linear;
-moz-transition: all .2s linear;
transition: all .2s linear;
}
.image:hover{
box-shadow:0px 0px 15px 0px black;
}
HTML:
<div class="image transition"></div>
這樣你可以申請轉變爲一個類
任何你想要的元素,並記住過渡是適用於你寫的每一件事:懸停。
here is a working Fiddle
,這裏是在列表中應用這樣的代碼:
CSS:
ul{list-style:none; float:left;}
ul li{margin:15px;}
.image{
width:200px;
height:200px;
background:red;
}
.transition{
-webkit-transition: all .2s linear;
-o-transition: all .2s linear;
-moz-transition: all .2s linear;
transition: all .2s linear;
}
.image:hover{
box-shadow:0px 0px 15px 0px black;
}
HTML:
<ul>
<li class="image transition"></li>
<li class="image transition"></li>
<li class="image transition"></li>
</ul>
<ul>
<li class="image transition"></li>
<li class="image transition"></li>
<li class="image transition"></li>
</ul>
和Fiddle一如既往
現在您只需將background:red;
屬性更換爲
background-image:url(yourimagepath.ext);
並且您應該準備好了。
如果您_think_可能與$ something有關 - 那麼您爲什麼不在你問之前研究一些東西? – CBroe 2013-04-10 12:14:30
CBroe - 我做了,找不到答案。所以我在這裏發佈了一個問題。如果你不喜歡這個,那麼請保留你的假設給你自己。 – hailthemelody 2013-04-10 12:49:36