Jquery 全屏图像与 Jquery 滚动

发布于 2024-12-23 04:15:46 字数 1912 浏览 1 评论 0原文

我正在使用 2 个不同的 jquery 插件,它们都工作正常,但由于某种原因我无法让它们一起工作。

全屏图像:

<script type="text/javascript">  
     var FullscreenrOptions = {  width: 1024, height: 439, bgID: '#bgimg' };
     // This will activate the full screen background!
     jQuery.fn.fullscreenr(FullscreenrOptions);

</script>

滚动到 div 功能:

function GotoSection(divid)
{
     $('#realBody').animate({scrollTop: $('#' + divid).offset().top}, 300);
    }

我的 html:

<!-- This is the background image -->
<img id="bgimg" src="img/background6.jpg" />
<!-- Here the "real" body starts, where you can put your website -->
<div id="realBody">
<div id="header">
    <div class="content">
         <img src="img/logo.png" align="left"/>
        <ul id="menu">
             <li><a id="mhome" name="home" class="selected" onclick="GotoSection('home');">Home</a></li>  
                    </ul>
             <div class="clear"></div>
    </div>    
</div>
<div id="container">
    <div id="home" class="seperator"></div>
            here is my home content
        </div>
    </div>
</div>

我的 css:

#bgimg {
position:absolute;
z-index: -1;
}

#realBody{
position:absolute;
z-index: 5; /* Place the new body above the background image */
overflow:auto;  /* restore scrollbars for the content */
height:100%;width:100%; /* Make the new body fill the screen */
top:120px;
}


body
{
height: 100%;
overflow: hidden;
background-color: #ffffff;  
padding: 0;
margin: 0;  
font-family:'HelveticaLTStdLight';
color:#0f508e;
}

滚动混乱,它不会转到我发送的 div。我认为我的错误在于这一行:

$('#realBody').animate({scrollTop: $('#' + divid).offset().top}, 300);  

但不确定我需要将其更改为什么。

I am using 2 different jquery plugins which both works fine but for some reason I can't get them to work together.

fullscreen image:

<script type="text/javascript">  
     var FullscreenrOptions = {  width: 1024, height: 439, bgID: '#bgimg' };
     // This will activate the full screen background!
     jQuery.fn.fullscreenr(FullscreenrOptions);

</script>

scroll to div function:

function GotoSection(divid)
{
     $('#realBody').animate({scrollTop: $('#' + divid).offset().top}, 300);
    }

my html:

<!-- This is the background image -->
<img id="bgimg" src="img/background6.jpg" />
<!-- Here the "real" body starts, where you can put your website -->
<div id="realBody">
<div id="header">
    <div class="content">
         <img src="img/logo.png" align="left"/>
        <ul id="menu">
             <li><a id="mhome" name="home" class="selected" onclick="GotoSection('home');">Home</a></li>  
                    </ul>
             <div class="clear"></div>
    </div>    
</div>
<div id="container">
    <div id="home" class="seperator"></div>
            here is my home content
        </div>
    </div>
</div>

my css:

#bgimg {
position:absolute;
z-index: -1;
}

#realBody{
position:absolute;
z-index: 5; /* Place the new body above the background image */
overflow:auto;  /* restore scrollbars for the content */
height:100%;width:100%; /* Make the new body fill the screen */
top:120px;
}


body
{
height: 100%;
overflow: hidden;
background-color: #ffffff;  
padding: 0;
margin: 0;  
font-family:'HelveticaLTStdLight';
color:#0f508e;
}

The scroll is messed up it doesn't go to the divs that i send. I think my error is in this line:

$('#realBody').animate({scrollTop: $('#' + divid).offset().top}, 300);  

but not sure what i need to change it to.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

秉烛思 2024-12-30 04:15:46

您的开始和结束 div 数量不匹配。尝试纠正这个问题,看看是否可以解决。

You have a mismatched number of opening and closing div's. Try correcting this and seeing if it fixes it.

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