我正在尝试设置导航与导航之外的交叉淡入淡出图像。但是在两者之间放置是行不通的。
所以我的意图是,如果单击主页、关于、工作或联系人,(一页)将加载内容,并且导航会显示当前页面的正确图像。
HTML: <div id="cf7" class="shadow">
<img class='opaque' src="/images/Cirques.jpg" />
<img src="/images/Clown%20Fish.jpg;" />
<img src="/images/Stones.jpg;" />
<img src="/images/Summit.jpg;" />
</div>
<p id="cf7_controls">
<span class="selected">Home</span>
<span>About</span>
<span>Work</span>
<span>Contact</span>
</p>
CSS
p#cf7_controls {
text-align:center;
}
#cf7_controls span {
padding-right:2em;
cursor:pointer;
}
#cf7 {
position:relative;
height:281px;
width:450px;
margin:0 auto 10px;
}
#cf7 img {
position:absolute;
left:0;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
opacity:0;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
}
#cf7 img.opaque {
opacity:1;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=1);
}
JAVASCRIPT
$(document).ready(function() {
$("#cf7_controls").on('click', 'span', function() {
$("#cf7 img").removeClass("opaque");
var newImage = $(this).index();
$("#cf7 img").eq(newImage).addClass("opaque");
$("#cf7_controls span").removeClass("selected");
$(this).addClass("selected");
});
});