Skip to content

Instantly share code, notes, and snippets.

@ds729
Created June 9, 2012 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ds729/2901164 to your computer and use it in GitHub Desktop.
Save ds729/2901164 to your computer and use it in GitHub Desktop.
画像置換1
/*
マウスオーバーでaの背景画像のopacityを1にする。CSS3のtransitionでもできる
li:hover{opacity:1;}
li{transition:0.5s;}
*/
div#header ul#header_menu li.header_link03 {
background-image: url(../images/header_link03.png);
background-repeat: no-repeat;
}
div#header ul#header_menu li.header_link03 a {
background-image: url(../images/header_link03.png);
background-position: -130px 0px;
}
div#header ul#header_menu li a {
display:block;
height:115px;
width:130px;
text-indent:-9999px;
}
<li class="header_link03">
<a href="#staff" style="opacity: 0; ">03 スタッフ</a>
</li>
$(document).ready(function(){
$(function() {
$("div#header ul#header_menu li a").css("opacity","0");
//初期設定として画像のopacityを0にします。
$("div#header ul#header_menu li a").hover( //hoverです。
function () {
$(this).stop().animate({opacity: 1}, 'fast');},
//マウスオーバー時にopacityを1にします。
function () {
$(this).stop().animate({opacity: 0}, 'fast');}
//マウスアウト時にopacityを0に戻します。
);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment