[英]How can I get jQuery to add a placeholder before the image is faded?
I am using this to fade elements on my page: 我正在使用它淡化页面上的元素:
$(document).ready(function() {
$('#holder').delay(650).fadeIn(1000);
$('#sidepanelHolder').delay(650).fadeIn(1000);
$('#bottomHolder').delay(1200).fadeIn(1000);
});
And this CSS to add a placeholder so the area isn't invisible then visible, moving whatever is under it: 并在此CSS中添加了一个占位符,以使该区域既不可见又不可见,移动其下方的内容:
.nope {
display: none;
width: auto;
height: auto;
}
HTML: HTML:
<article class="featureBottom">
<div id="bottomHolder" class="nope">
<img src="/images/features/one.jpg" width="100%" alt="" />
</div>
</article>
I am leaving the id
undefined, just using it for jQuery... 我将id
未定义状态,仅将其用于jQuery ...
The fading images for #holder
and #sidePanelHolder
work fine, but the #bottomHolder
is not working: #holder
和#sidePanelHolder
的褪色图像可以#holder
工作,但是#bottomHolder
无法正常工作:
.featureBottom {
max-width: 1400px;
margin: 20px auto 20px auto;
padding: 0;
display: block;
}
Is there an easier way to add placeholders that are the height and width of whatver you are fading, so that it fades without going from hidden
to block
, moving elements down the page underneath the faders. 有没有一种简单的方法可以添加占位符,该占位符是您要淡入的东西的高度和宽度,因此它可以淡入淡出而不会从hidden
变为block
,而是将元素向下移动到淡入淡出之下的页面中。
Hope that makes sense :-) 希望有道理:-)
Thanks in advance 提前致谢
EDIT: 编辑:
This is the page before the image fades: 这是图像消失之前的页面:
The placeholder is not present here. 占位符不在此处。 The S's and the footer (change of background texture) are close together. S和页脚(背景纹理的变化)靠在一起。
Then the image loads: 然后图像加载:
Pushing the footer down, the auto
height & width for .nope
is not obeyed here, like they are for my other two faders on the same page: holder
and sidepanelHolder
. 向下推动页脚,此处不会遵守.nope
的auto
高度和宽度,就像我在同一页面上的其他两个推子一样: holder
和sidepanelHolder
。
Use a callback or several callbacks. 使用一个或多个回调。 That way the others don't start their fadeIn until the first is done. 这样,其他人就不会开始淡入,直到第一个完成。 See this post . 看到这篇文章 。
A call back changes your code to look like this 回调会将您的代码更改为如下形式
$(document).ready(function() {
$('#holder').delay(650).fadeIn(1000,function(){
$('#sidepanelHolder').delay(650).fadeIn(1000);
$('#bottomHolder').delay(1200).fadeIn(1000);
});
});
If you want your footer to stay at the bottom of the page the entire time, try this trick from CSS-Tricks https://css-tricks.com/snippets/css/sticky-footer/ 如果您希望页脚始终停留在页面底部,请尝试从CSS-Tricks https://css-tricks.com/snippets/css/sticky-footer/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.