jQuery fadeIn淡出背景问题
jQuery fadeIn fadeOut background problem
当我fadeIn一个div,动画结束时,背景突然消失了(这一次只在Firefox中)。我有一个容器,里面有两个嵌套的元素。第二个元素有一个负边距,所以它出现在第一个元素的顶部。
我的脚本:
jQuery(document).ready(function($) {
$(".second_element").hide();
$(".container").each(function () {
$(this).mouseover(function () {
$(this).children(".second_element").stop(true, true);
$(this).children(".second_element").fadeIn(250, 'linear');
});
$(this).mouseout(function () {
$(this).children(".second_element").stop(true, true);
$(this).children(".second_element").fadeOut(100, 'linear');
});
});
});
CSS:
.container{
width: 221px;
height: 202px;
display: block;
float: left;
position: relative;
}
.first_element {
height: 200px;
width: 219px;
}
.second_element {
display:none;
background: #fff !important;
margin-top: -51px;
width: 219px;
height: 50px;
}
为清楚起见,这是一个HTML示例
<td class="container">
<div id="first_element">...</div>
<div id="second_element">...</div>
</td>
我的第二个问题是,当我的鼠标悬停在第二个元素上方时,函数再次执行(因此第二个元素淡出和进入)。而第二个元素只是在容器
这更短,而且,对于第一次运行,最好由fadeOut()
而不是hide()
隐藏目标
$(".caption").fadeOut(1);
$(".container").each(function() {
$(this).mouseover(function() {
$(".caption", this).stop().fadeIn(250);
});
$(this).mouseout(function() {
$(".caption", this).stop().fadeOut(250);
});
});
补充最后的注释;我明白了。我尝试了几种方式,也用标题position: absolute
,但我不得不将第一个元素设置为position: absolute
…现在它工作了(但不是褪色,但这是好的)。非常感谢您的帮助和支持!
相关文章:
- 使用Javascript对象为具有两个背景图像的DIV设置样式时出现问题
- 背景定位下拉菜单问题
- 苹果/野生动物园在移动设备上播放背景视频时出现问题
- SVG模式动画和背景淡入问题
- 背景重叠问题
- iOS 8中滚动时的背景图像闪烁问题
- 尝试在页面刷新时更改背景图像,遇到问题
- 覆盖在“背景大小:包含”上的响应式 DIV - 解决警报触发的问题
- 背景图像不透明度问题
- 将鼠标悬停在 li 元素上时更改背景的问题
- 使用 .css() jQuery 方法更改背景图像时出现问题
- 显示背景图像时出现问题
- 活动时更改菜单项背景的问题
- 浏览器和移动设备的视差背景问题(javascript/jquery)
- 预加载css背景图像,nivo滑块问题
- 拉伸背景以适应iPhone屏幕的问题
- CSS背景颜色问题
- backstretch导致chrome中的其他背景图像出现问题
- 如果背景等于问题
- 在IE和Chrome中使用Javascript获取背景图像的问题