2013-03-14 76 views
1

我正在使用Jquery来构建移动应用程序,我想显示一个带有大量文本的小弹出框。popup is 30% of the screen和我想要的文本将是scrollable带手机小scrollerbar。Jquery带小滚动条的弹出div像移动

这是我的弹出窗口:

<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'); 

有什么想法吗?

回答

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>