首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >加载页面时,JQuery停止在屏幕上显示页面

加载页面时,JQuery停止在屏幕上显示页面
EN

Stack Overflow用户
提问于 2012-02-17 18:21:22
回答 3查看 1.4K关注 0票数 0

我正在使用这个脚本:http://wpaoli.building58.com/2009/09/jquery-tab-slide-out-plugin/

它工作得很好,但我的问题是,当页面加载时,div显示在屏幕的中间……然后在页面加载后滑入适当的位置。

只是看到一个大的div出现在屏幕上看起来并不好。

有没有办法阻止这种情况的发生?

代码如下:

代码语言:javascript
复制
<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>
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-02-17 18:26:48

使用CSS从start隐藏div:

代码语言:javascript
复制
.slide-out-div {
    padding: 20px;
    width: 700px;
    background: #ffffff;
    border: 1px solid #ffffff;
    position:relative;
    z-index:999;
    display: none;
}

然后在页面加载后显示div:

代码语言:javascript
复制
$('.slide-out-div').show().tabSlideOut({
  ...
票数 1
EN

Stack Overflow用户

发布于 2012-02-17 18:24:38

只需将display:none添加到类定义中:

代码语言:javascript
复制
<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
EN

Stack Overflow用户

发布于 2012-06-28 23:31:31

我使用了Guffa的解决方案,但必须更改其中的一部分。我没有编辑他的答案,而是修改如下:

使用CSS隐藏开始时的滑块:

代码语言:javascript
复制
.slide-out-div {
    padding: 20px;
    width: 700px;
    background: #ffffff;
    border: 1px solid #ffffff;
    position:relative;
    z-index:999;
    display: none;
}

然后将新的SHOW代码放在初始tabslideout声明之后:

代码语言:javascript
复制
$(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()
    });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9326481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档