页面加载时,JQuery Stop Div 显示在屏幕上

发布于 2025-01-06 17:29:01 字数 2110 浏览 0 评论 0原文

我正在使用这个脚本: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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暗藏城府 2025-01-13 17:29:01

使用 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({
  ...

Use the CSS to hide the div from start:

.slide-out-div {
    padding: 20px;
    width: 700px;
    background: #ffffff;
    border: 1px solid #ffffff;
    position:relative;
    z-index:999;
    display: none;
}

Then show the div when the page has loaded:

$('.slide-out-div').show().tabSlideOut({
  ...
憧憬巴黎街头的黎明 2025-01-13 17:29:01

只需将 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>

Simply add display:none to the class definition:

<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>
所有深爱都是秘密 2025-01-13 17:29:01

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

使用 CSS 从开始隐藏滑块:

.slide-out-div {
    padding: 20px;
    width: 700px;
    background: #ffffff;
    border: 1px solid #ffffff;
    position:relative;
    z-index:999;
    display: none;
}

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

$(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()
    });

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:

.slide-out-div {
    padding: 20px;
    width: 700px;
    background: #ffffff;
    border: 1px solid #ffffff;
    position:relative;
    z-index:999;
    display: none;
}

Then place the new SHOW code after the initial tabslideout declaration:

$(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()
    });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文