Jscrollpane插件解决弹出框问题
我正在使用 jscrollpane jquery 插件来应用弹出 div 框(简称 lightbox),但 jscrollpane 滚动条不显示。这是 html:
{
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-1.4.4.js"></script>
<link type="text/css" href="style/jquery.jscrollpane.css" rel="stylesheet" media="all"></link>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="JScrollPaneScripts/jquery.mousewheel.js"></script>
<script type="text/javascript" src="JScrollPaneScripts/jquery.jscrollpane.min.js"></script>
<link rel = "stylesheet" type = "text/css" href = "sample1.css"></link>
<script type="text/javascript">
$( document ).ready( function( )
{
$( function( )
{
$( '#testing2' ).jScrollPane( );
});
$( "#testing" ).click( function( )
{
$( "#testing2" ).show( 5000 );
});
}
);
</script>
</head>
<body>
<div id = "wrapperdiv">
<a id = "testing" href="#">Link</a>
<div id = "testing2">
lksjflksjdlkflskdjflksjdflkjslkjdflk
lsdkflksjgliowtjlskdfjlskdfjlskgs
lksjlk,.x,cmlkvjlkjlwkeoltklfnjsklkj
lksjf.m,.jlkjoliwekjtlkjgkjjlkjlkjll
llvalkiwujoitjlkgskjdkgjlsd,fjlsllll
lksjflksjdlkflskdjflksjdflkjslkjdflk
lsdkflksjgliowtjlskdfjlskdfjlskgs
lksjlk,.x,cmlkvjlkjlwkeoltklfnjsklkj
lksjf.m,.jlkjoliwekjtlkjgkjjlkjlkjll
llvalkiwujoitjlkgskjdkgjlsd,fjlsllll
lksjflksjdlkflskdjflksjdflkjslkjdflk
lsdkflksjgliowtjlskdfjlskdfjlskgs
lksjlk,.x,cmlkvjlkjlwkeoltklfnjsklkj
lksjf.m,.jlkjoliwekjtlkjgkjjlkjlkjll
llvalkiwujoitjlkgskjdkgjlsd,fjlsllll
lksjflksjdlkflskdjflksjdflkjslkjdflk
lsdkflksjgliowtjlskdfjlskdfjlskgs
lksjlk,.x,cmlkvjlkjlwkeoltklfnjsklkj
lksjf.m,.jlkjoliwekjtlkjgkjjlkjlkjll
llvalkiwujoitjlkgskjdkgjlsd,fjlsllll
lksjflksjdlkflskdjflksjdflkjslkjdflk
lsdkflksjgliowtjlskdfjlskdfjlskgs
lksjlk,.x,cmlkvjlkjlwkeoltklfnjsklkj
lksjf.m,.jlkjoliwekjtlkjgkjjlkjlkjll
llvalkiwujoitjlkgskjdkgjlsd,fjlsllll
</div>
</div>
</body>
</html>
}
这是 css:
*
{
padding: 0px;
margin: 0px;
}
#wrapperdiv
{
width: 1000px;
margin: 500px auto 0px auto;
}
#testing
{
width: 100px;
height: 50px;
border: 1px solid;
font-size: 22px;
display: block;
text-align: center;
padding: 25px 0px 0px 0px;
}
#testing2
{
display: none;
width: 270px;
height: 300px;
background: yellow;
border: 1px solid;
bottom: 100px;
left: 10%;
position: relative;
z-index: 999;
}
I'm using the jscrollpane jquery plugin to be applied for a pop up div box(lightbox for short), but the jscrollpane scroll bar does not show up. Here is the html:
{
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-1.4.4.js"></script>
<link type="text/css" href="style/jquery.jscrollpane.css" rel="stylesheet" media="all"></link>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="JScrollPaneScripts/jquery.mousewheel.js"></script>
<script type="text/javascript" src="JScrollPaneScripts/jquery.jscrollpane.min.js"></script>
<link rel = "stylesheet" type = "text/css" href = "sample1.css"></link>
<script type="text/javascript">
$( document ).ready( function( )
{
$( function( )
{
$( '#testing2' ).jScrollPane( );
});
$( "#testing" ).click( function( )
{
$( "#testing2" ).show( 5000 );
});
}
);
</script>
</head>
<body>
<div id = "wrapperdiv">
<a id = "testing" href="#">Link</a>
<div id = "testing2">
lksjflksjdlkflskdjflksjdflkjslkjdflk
lsdkflksjgliowtjlskdfjlskdfjlskgs
lksjlk,.x,cmlkvjlkjlwkeoltklfnjsklkj
lksjf.m,.jlkjoliwekjtlkjgkjjlkjlkjll
llvalkiwujoitjlkgskjdkgjlsd,fjlsllll
lksjflksjdlkflskdjflksjdflkjslkjdflk
lsdkflksjgliowtjlskdfjlskdfjlskgs
lksjlk,.x,cmlkvjlkjlwkeoltklfnjsklkj
lksjf.m,.jlkjoliwekjtlkjgkjjlkjlkjll
llvalkiwujoitjlkgskjdkgjlsd,fjlsllll
lksjflksjdlkflskdjflksjdflkjslkjdflk
lsdkflksjgliowtjlskdfjlskdfjlskgs
lksjlk,.x,cmlkvjlkjlwkeoltklfnjsklkj
lksjf.m,.jlkjoliwekjtlkjgkjjlkjlkjll
llvalkiwujoitjlkgskjdkgjlsd,fjlsllll
lksjflksjdlkflskdjflksjdflkjslkjdflk
lsdkflksjgliowtjlskdfjlskdfjlskgs
lksjlk,.x,cmlkvjlkjlwkeoltklfnjsklkj
lksjf.m,.jlkjoliwekjtlkjgkjjlkjlkjll
llvalkiwujoitjlkgskjdkgjlsd,fjlsllll
lksjflksjdlkflskdjflksjdflkjslkjdflk
lsdkflksjgliowtjlskdfjlskdfjlskgs
lksjlk,.x,cmlkvjlkjlwkeoltklfnjsklkj
lksjf.m,.jlkjoliwekjtlkjgkjjlkjlkjll
llvalkiwujoitjlkgskjdkgjlsd,fjlsllll
</div>
</div>
</body>
</html>
}
Here is the css:
*
{
padding: 0px;
margin: 0px;
}
#wrapperdiv
{
width: 1000px;
margin: 500px auto 0px auto;
}
#testing
{
width: 100px;
height: 50px;
border: 1px solid;
font-size: 22px;
display: block;
text-align: center;
padding: 25px 0px 0px 0px;
}
#testing2
{
display: none;
width: 270px;
height: 300px;
background: yellow;
border: 1px solid;
bottom: 100px;
left: 10%;
position: relative;
z-index: 999;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jScrollPane 不适用于初始化时不可见的项目。这是因为它无法计算其应有的大小。因此,您需要在显示内容后重新初始化 jScrollPane,如下例所示:
http://jscrollpane.kelvinluck.com /invisibles.html
可以将回调作为 jQuery show 的第二个参数提供,以便您可以将:替换
为:
作为旁注,HTML 中
=
符号周围的空格可能会阻止其验证...jScrollPane doesn't work on items which are invisible when you initialise it. This is because it can't calculate the size that it is meant to be. So you need to reinitialise jScrollPane after showing the content as shown in this example:
http://jscrollpane.kelvinluck.com/invisibles.html
A callback can be provided as the second parameter to jQuery show so you can replace:
with:
As a side note, the spaces around the
=
signs in your HTML will probably stop it from validating...有几件事要尝试:
如果我没记错的话,元素必须应用 css 属性,
因此请将其粘贴到 #testing2 的 css 中。
问题是因为您的目标元素被隐藏,因此您可以尝试在显示功能后初始化scrollPane:
尝试不使用该元素隐藏看看是否可以正常工作。
另请查看这些链接 - comment5:http://code.google。 com/p/jscrollpane/issues/detail?id=30
在这种情况下,我上面的代码将变成
http://jscrollpane.kelvinluck.com/invisibles.html - 解释了在不可见元素上使用它
A Few things to try:
If I recall correctly elements must have the css property
applied so stick that into your css for #testing2
The issue because the element your targeting is hidden so you could try initializing scrollPane after the show function:
Try without the element hidden to see if that works ok.
Also check out these links - comment5 here: http://code.google.com/p/jscrollpane/issues/detail?id=30
in which case my above code would become
and http://jscrollpane.kelvinluck.com/invisibles.html - which explains using it on invisble elements