我正在使用此脚本: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>
答案 0 :(得分:1)
只需将display:none
添加到类定义中:
<style type="text/css">
.slide-out-div {
display:none;
padding: 20px;
width: 700px;
background: #ffffff;
border: 1px solid #ffffff;
position:relative;
z-index:999;
}
</style>
答案 1 :(得分:1)
使用CSS隐藏div从开始:
.slide-out-div {
padding: 20px;
width: 700px;
background: #ffffff;
border: 1px solid #ffffff;
position:relative;
z-index:999;
display: none;
}
然后在页面加载时显示div:
$('.slide-out-div').show().tabSlideOut({
...
答案 2 :(得分:0)
我使用了Guffa的解决方案,但不得不改变一部分。我没有编辑他的答案,而是将其修改如下:
使用CSS从开始隐藏滑块:
.slide-out-div {
padding: 20px;
width: 700px;
background: #ffffff;
border: 1px solid #ffffff;
position:relative;
z-index:999;
display: none;
}
然后在初始的tablideout声明之后放置新的SHOW代码:
$(function(){
$('.slide-out-div').tabSlideOut({
tabHandle: '.handle',
pathToTabImage: 'image_button.gif',
imageHeight: '122px',
imageWidth: '37px',
tabLocation: 'left',
speed: 300,
topPos: '79px',
leftPos: '20px',
fixedPosition: false
});
$('.slide-out-div').show()
});