[CSS]ホバー時に素敵なエフェクトでパネルを変更するスタイルシート
Post on:2011年6月20日
sponsorsr
マウスのホバー時に、素敵なアニメーションでパネルを変更するスタイルシートを紹介します。

[ad#ad-2]
デモではパネルにマウスホバーすると、背景を変更しアニメーションのエフェクトを適用します。
実装方法
HTML
HTMLはシンプルです。
ポイントとなるのは、h3やpなどのブロック要素をa要素で内包している点です。これはHTML5を使用する限りvalidです。
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<a href="#" class="hover-panel">
<h3>Panel Title</h3>
<p>Additional information about the panel goes in a paragraph here</p>
</a>
</body>
</html>
[ad#ad-2]
CSS:ノーマル時のスタイリング
まずは、ノーマル時のスタイリングから。
.hover-panel {
background-color: #E6E2DF;
color: #B2AAA4;
float: left;
height: 130px;
width: 262px;
margin: 0 10px 10px 0;
padding: 15px;
}
.hover-panel h3 {
font-family: tandelle-1, tandelle-2, Impact, Sans-serif, sans;
font-size: 38px;
line-height: 1;
margin: 0 0 10px;
text-transform: uppercase;
}
.hover-panel p {
font-size: 12px;
width: 65%;
}
CSS:ホバー時のスタイリング
次にホバー時のスタイリングを行います。
.hover-panel:hover {
background-color: #237ABE;
}
.hover-panel:hover h3 {
color: #FFF;
text-shadow: rgba(0, 0, 0, 0.398438) 0px 0px 4px;
}
.hover-panel:hover p {
color: #FFF:
}
次に、ホバー時の背景画像を加えます。
.hover-panel {
background-image: url(hover-panel-icon.png);
background-position: 292px 10px;
background-repeat: no-repeat;
}
.hover-panel:hover {
background-position: 180px 10px;
}
CSS:アニメーション
最後にアニメーションのエフェクトです。
.hover-panel {
-moz-transition: all 0.2s ease; /* FF3.7+ */
-o-transition: all 0.2s ease; /* Opera 10.5 */
-webkit-transition: all 0.2s ease; /* Saf3.2+, Chrome */
transition: all 0.2s ease;
}
sponsors











