1

我正在使用 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');

有任何想法吗?

4

2 回答 2

1

您可以webkit scrollbars使用自定义CSS

阅读这篇文章了解更多详情:http ://css-tricks.com/custom-scrollbars-in-webkit/

于 2013-03-14T09:34:38.280 回答
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>

于 2013-03-14T14:22:35.063 回答