這可能被問了很多,我看到了一大堆不同的解決方案,其中一些我不能自己工作。jQuery圖像翻轉褪色
我的目標是建立一個菜單,但是,從一開始,最好先讓一個按鈕工作,是嗎?
於是,我就跟着Dragon Interactive教程
繼承人我的代碼:
CSS:
#navigation a {
position: relative;
}
#navigation a .hover {
display: block;
position: absolute;
top: 0px;
left: 0px;
height: 100%;
width: 100%;
}
的Javascript:
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$(".hover").css({'opacity':'0'});
$('#navigation li a').hover(function() {
// Stuff that happens when you hover on
$('.hover').animate({
'opacity': 1
}, 700)
},function() {
// Stuff that happens when you unhover
$('.hover').animate({
'opacity': 0
}, 700)
});
});
</script>
當然和HTML標記。
<p>
Just some random giberish here, to make sure the positioning
<br>
works regardless of what junk I have before and after it. :)
</p>
<ul id="navigation" style="list-style-type: none; list-style-position:outside;">
<li>
<a href="http://google.com"><img id="btn1" border="none" src="https://dom28edjsbv6i.cloudfront.net/Images/GetPlan.png" />
</a><span class="hover"><img src="https://dom28edjsbv6i.cloudfront.net/Images/GetPlan_MO.png" /></span>
</li>
</ul>
我試過改變不同的參數,我完全失去了。
我應該使用div,併爲背景圖片設置動畫效果嗎?這會產生相同的「img」鏈接效果,還是僅僅是錯誤的編碼?
基本上,我問的是一個可複製的最小解決方案。 :)
我認爲懸停是哈弗(IN,OUT)?我正在尋找一個JS方法,並不是很多瀏覽器都支持CSS3 AFAIK :) – Jeff
如何爲SRC更改設置動畫?這將是最好的解決方案! – Jeff
我已經添加了一種方法的演示,克隆「
」併爲克隆的不透明度設置動畫。 –
andyb