Here’s the brief…
I need to paginate very long amounts of text using jQuery or javascript.
Now I have thought about doing character counts etc but the problem is that I’m not using monospace text so that’s won’t work.
Instead I’m using dynamically entered text (straight from my best friend wordpress).
Here’s the setup:
I have placed the text in a div called bodytext which has overflow set to auto. Here’s it’s styling:
.bodytext {
width: 465px;
height: 454px;
display: block;
position: absolute;
display: block;
margin: 136px 25px;
font-family: 'Gentium Basic', serif;
color: #141414;
line-height: 1.5;
line-height: 1.5;
font-size: 17px;
overflow: hidden;
}
Anyway… the text overflows.
What I want to do is create a series of div’s (with the bodytext class) all beside eachother that I can hook my buttons up to to toggle between.
I have found this good bit of information out though: every 18 lines I need to create a new div.
I have no idea how to work this out though.
I also need it to be able to handle large quantities of text… perhaps up to 1000 words at a time… resulting in say 10 pages…
any help would be lovely!
Thanks for reading!
This proof-of-concept will work (also with css3 columns), but be warned, there is a CPU cost; it’s DOM-intensive and jQuery is required.
This requires the text to be divided into shorter paragraps (or any other tag), but it should be possible to even do that clientside if the text is in too big chunks.
Pseudo-markup:
Code:
CSS3 Multiple column layout would do the job assuming that your target browsers support it: http://caniuse.com/#feat=multicolumn
You need outer div which crops text, inner div with columns having fixed width and height and buttons which would modify margin left of inner div.
Many features are only partially supported (according to my experience Opera performs the best), but it should be enough for many cases. See http://www.w3.org/TR/css3-multicol/ where you can find many good examples (esp. example XXIII, “Pagination and overflow outside multicol elements”).