我正在使用Jquery构建移动应用程序,我想显示一个包含大量文本的小弹出框。popup is 30% of the screen
我希望文本为scrollable
,带有移动小滚动条
这是我的弹出窗口:
<div id="popup" class= "DivWithScroll">
<div class="txt">
<p id="text"> textData...textData...textData</p>
</div>
</div>
尝试使用此CSS,但其windows scroller
- 不是我需要的
.DivWithScroll{
height:120px;
overflow:scroll;
overflow-x:hidden;
}
尝试使用插件iscroll.js
。看到了一些例子,但没有得到我想要的东西。
myScroll = new iScroll('popup');
任何想法?
答案 0 :(得分:1)
您可以使用webkit scrollbars
自定义CSS
。
阅读这篇文章了解更多详情:http://css-tricks.com/custom-scrollbars-in-webkit/
答案 1 :(得分:1)
我为你做了一个例子:
首先创建了一个弹出窗口,并应用了webkit滚动
风格:
http://css-tricks.com/custom-scrollbars-in-webkit/
试一试:
$(function(){
// content of the pop up
var content = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).";
// add pop up to the window
$("body").append("<div id='PopUp'>" + content + "</div>");
// css properties
$("#PopUp").css({
"height":"300px",
"width":"300px",
"border":"1px solid #AAA",
"background-color":"#FFF",
"position":"fixed",
"top":"50%",
"left":"50%",
"margin-top":"-150px",
"margin-left":"-150px",
"overflow-y":"scroll"
});
});
::-webkit-scrollbar {
width: 12px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>