jQuery 淡入问题
我正在尝试使用 jQuery、html 和 html 创建淡入淡出效果。 CSS 没有用。基本上,它是一个使用 jQuery 具有画廊滚动效果的导航列表。滚动联系人链接会弹出一个弹出窗口,其中包含服务的联系信息等,关于等等。
我使用的画廊脚本可以在 这里
每当我应用 .fadein(slow) 时,我都会得到想要的效果但相反。而不是从透明褪色到不透明::: 你得到了图片。我也尝试
.animate({opacity: '0.5'}, 1000)
过与上面相同的结果
我的 jOuery 脚本看起来像:
<script type>
$(document).ready(function() {
// Image swap on hover
$("#gallery ul li img").hover(function(){
$('#main-img').stop().fadeTo('slow',0.3).siblings()
.stop().fadeTo('slow',1.0).attr('src',$(this).attr('src').replace('thumb/', ''));
});
// Image preload
var imgSwap = [];
$("#gallery ul li img").each(function(){
imgUrl = this.src.replace('thumb/', '');
imgSwap.push(imgUrl);
});
$(imgSwap).preload();
});
$.fn.preload = function() {
this.each(function(){
$('<img/>')[0].src = this;
});
}
</script>
html:
<div id="left_nav">
<div id="gallery">
<img src="images/gallery/home.png" alt="" id="main-img" />
<ul>
<li class="home"><img src="images/gallery/thumb/home.png" alt="" /></li>
<li class="about"><img src="images/gallery/thumb/About Us.png" alt="" /></li>
<li class="contact"><img src="images/gallery/thumb/Contact Us.png" alt="" /></li>
<li class="services"><img src="images/gallery/thumb/Services.png" alt="" /></li>
</ul>
</div>
</div>
我也尝试过反转不透明度设置,因为这看起来像是常识。这只会产生不透明的效果,不会淡入。我要拍摄的是拇指悬停状态的淡入效果。另外,淡入淡出脚本似乎在 IE 8 中不起作用。有什么想法吗?
I'm trying to create a fade in effect using jQuery, html & CSS with no avail. Basically, it's a navigation list with a gallery scroll effect using jQuery.. scrolling over contact link brings a popup with contact info and so on for services, about etc..
The gallery script I used can be found here
whenever I apply .fadein(slow), I get the desired affect but in reverse. Instead of fading from transparent to opaque:::you get the picture. I have also tried
.animate({opacity: '0.5'}, 1000)
with the same results as above
What my jOuery script looks like:
<script type>
$(document).ready(function() {
// Image swap on hover
$("#gallery ul li img").hover(function(){
$('#main-img').stop().fadeTo('slow',0.3).siblings()
.stop().fadeTo('slow',1.0).attr('src',$(this).attr('src').replace('thumb/', ''));
});
// Image preload
var imgSwap = [];
$("#gallery ul li img").each(function(){
imgUrl = this.src.replace('thumb/', '');
imgSwap.push(imgUrl);
});
$(imgSwap).preload();
});
$.fn.preload = function() {
this.each(function(){
$('<img/>')[0].src = this;
});
}
</script>
The html:
<div id="left_nav">
<div id="gallery">
<img src="images/gallery/home.png" alt="" id="main-img" />
<ul>
<li class="home"><img src="images/gallery/thumb/home.png" alt="" /></li>
<li class="about"><img src="images/gallery/thumb/About Us.png" alt="" /></li>
<li class="contact"><img src="images/gallery/thumb/Contact Us.png" alt="" /></li>
<li class="services"><img src="images/gallery/thumb/Services.png" alt="" /></li>
</ul>
</div>
</div>
I have also tried reversing the opacity settings because it would seem like common sense. This results in an opaque affect only, no fade in. What I'm shooting for is a fade in affect for hover state of thumbs. Also, fade script doesn't seem to work in IE 8. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
哇,这里发生了一些链接。为什么你也必须淡入兄弟姐妹(即 ul 标签)?也许你的意思是这个?
是故意松开的。由于某种原因,将 hide 和 fadeIn 调用链接在一起可能会使其在某些浏览器(例如 IE)中停止工作。
Wow, some chaining going on here. Why do you have to fade in the siblings as well (i.e. the ul tag) ? Maybe you meant this?
It's deliberately unchained. For some reason, chaining the hide and fadeIn calls together can make it stop working in some browsers, like IE.
我猜你必须先将不透明度设置为 0,然后再淡入 0.5 或任何值。
如果不透明度为 1 并且您告诉它淡入到 0.5,它将从 1 -> 变为 0.5。 0.5。
I guess you have to set opacity to 0 prior to fading into 0.5 or whatever value.
If opacity is 1 and you tell it to fade to 0.5 it will go from 1 -> 0.5.