Jquery 全屏图像与 Jquery 滚动
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的开始和结束 div 数量不匹配。尝试纠正这个问题,看看是否可以解决。
You have a mismatched number of opening and closing div's. Try correcting this and seeing if it fixes it.