页面加载时,JQuery Stop Div 显示在屏幕上
我正在使用这个脚本:http://wpaoli.building58。 com/2009/09/jquery-tab-slide-out-plugin/
它工作得很好,但我的问题是,当页面加载时,div 出现在屏幕中间......然后滑入页面加载后的位置。
看到屏幕上出现一个大 div 看起来不太好。
有办法阻止这种情况发生吗?
这是代码:
<script src="http://tab-slide-out.googlecode.com/files/jquery.tabSlideOut.v1.3.js"></script>
<script type="text/javascript">
$(function(){
$('.slide-out-div').tabSlideOut({
tabHandle: '.handle', //class of the element that will become your tab
pathToTabImage: 'image_button.gif', //path to the image for the tab //Optionally can be set using css
imageHeight: '122px', //height of tab image //Optionally can be set using css
imageWidth: '37px', //width of tab image //Optionally can be set using css
tabLocation: 'left', //side of screen where tab lives, top, right, bottom, or left
speed: 300, //speed of animation
action: 'click', //options: 'click' or 'hover', action to trigger animation
topPos: '79px', //position from the top/ use if tabLocation is left or right
leftPos: '20px', //position from left/ use if tabLocation is bottom or top
fixedPosition: false //options: true makes it stick(fixed position) on scroll
});
});
</script>
<style type="text/css">
.slide-out-div {
padding: 20px;
width: 700px;
background: #ffffff;
border: 1px solid #ffffff;
position:relative;
z-index:999;
}
</style>
....
<div class="slide-out-div">
<a class="handle" href="#">Content</a>
<h3>Title Here</h3>
<p>Text here</p>
</div>
I am using this script: http://wpaoli.building58.com/2009/09/jquery-tab-slide-out-plugin/
It works well but my problem is that the div show up in the middle of the screen when the page is loading ... and then Slides into position after the page loads.
It just doesn't look good to see a big div just appearing on the screen.
Is there a way to stop this happening?
This is the code:
<script src="http://tab-slide-out.googlecode.com/files/jquery.tabSlideOut.v1.3.js"></script>
<script type="text/javascript">
$(function(){
$('.slide-out-div').tabSlideOut({
tabHandle: '.handle', //class of the element that will become your tab
pathToTabImage: 'image_button.gif', //path to the image for the tab //Optionally can be set using css
imageHeight: '122px', //height of tab image //Optionally can be set using css
imageWidth: '37px', //width of tab image //Optionally can be set using css
tabLocation: 'left', //side of screen where tab lives, top, right, bottom, or left
speed: 300, //speed of animation
action: 'click', //options: 'click' or 'hover', action to trigger animation
topPos: '79px', //position from the top/ use if tabLocation is left or right
leftPos: '20px', //position from left/ use if tabLocation is bottom or top
fixedPosition: false //options: true makes it stick(fixed position) on scroll
});
});
</script>
<style type="text/css">
.slide-out-div {
padding: 20px;
width: 700px;
background: #ffffff;
border: 1px solid #ffffff;
position:relative;
z-index:999;
}
</style>
....
<div class="slide-out-div">
<a class="handle" href="#">Content</a>
<h3>Title Here</h3>
<p>Text here</p>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 CSS 从一开始就隐藏 div:
然后在页面加载时显示 div:
Use the CSS to hide the div from start:
Then show the div when the page has loaded:
只需将
display:none
添加到类定义中即可:Simply add
display:none
to the class definition:我使用了Guffa的解决方案,但必须更改一部分。我没有编辑他的答案,而是在下面修复了它:
使用 CSS 从开始隐藏滑块:
然后将新的 SHOW 代码放在初始 tabslideout 声明之后:
I used Guffa's solution, but had to change one part. Instead of editing his answer, I've fixed it below:
Use the CSS to hide the slider from start:
Then place the new SHOW code after the initial tabslideout declaration: