これが動作するデモですhttp://jsfiddle.net/pomeh/U4dyE/この効果を行うのにJavascriptは必要ありません、コードを見てください:)
HTMLコード
<div id="container">
<div class="wrap">
<div class="box"></div>
<div class="box"></div>
</div>
</div>
CSSコード
#container {
width: 300px;
height: 300px;
}
/* DRY :) */
.wrap, .box {
width: 50px;
height: 50px;
float: left;
margin: 1px 1px 1px 1px;
}
.box {
background-color: red;
opacity: 1;
filter:alpha(opacity=100);
/* animation for "mouse out" */
-webkit-transition: opacity 0.5s linear; /* Saf3.2+, Chrome */
-moz-transition: opacity 0.5s linear; /* FF4+ */
-ms-transition: opacity 0.5s linear; /* IE10 */
-o-transition: opacity 0.5s linear; /* Opera 10.5+ */
transition: opacity 0.5s linear;
}
.box:hover {
opacity: 0.5;
filter:alpha(opacity=50);
/* animation for "mouse in" */
-webkit-transition: opacity 0.5s linear; /* Saf3.2+, Chrome */
-moz-transition: opacity 0.5s linear; /* FF4+ */
-ms-transition: opacity 0.5s linear; /* IE10 */
-o-transition: opacity 0.5s linear; /* Opera 10.5+ */
transition: opacity 0.5s linear;
}
</ p>
JSコード
// absolutely none ! :)