Reputation: 131
I am using an Jquery for building a mobile app, I want to display a small popup box with a lot of text.The popup is 30% of the screen
and I want the text would be scrollable
with mobile small scrollerbar.
this is my popup window:
<div id="popup" class= "DivWithScroll">
<div class="txt">
<p id="text"> textData...textData...textData</p>
</div>
</div>
tried with this CSS, but its windows scroller
- not what I need
.DivWithScroll{
height:120px;
overflow:scroll;
overflow-x:hidden;
}
Tried using an plugin iscroll.js
. saw some examples but didn't got what I wanted.
myScroll = new iScroll('popup');
any ideas?
Upvotes: 1
Views: 6763
Reputation: 2261
I made an example for you:
First of all created a pop up window, and applied webkit scrolls
style :
http://css-tricks.com/custom-scrollbars-in-webkit/
Try It:
$(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>
Upvotes: 1
Reputation: 5168
You can customize webkit scrollbars
using CSS
.
Read this post for furhter details: http://css-tricks.com/custom-scrollbars-in-webkit/
Upvotes: 1