I need to split the html content into pages so that each page has a screen height and some predetermined width. Page splitting can occur in the middle of a paragraph (or, possibly, in some other html element), so this situation needs to be handled somehow.
What I really want to achieve is the effect of reading a book, page by page. I suppose some kind of javascript will be needed, so I would prefer it with jQuery, but if a different structure is required, this is also good.
I have to admit that I'm completely new to HTML and that's it, so sorry if my guess is stupid, but I'm currently considering the following approach: measure the actual height of the visible area (you need to figure out how else), then take my html document and step by step take the tag after the tag, put it in an invisible div and calculate its final height. When I have a height above the height of the page, I will finish. However, this approach will not work in the case of long labels, for example. long paragraph.
Thanks in advance.
EDIT : thanks for your previous answers. I tried using the approach of manually calculating the size of elements and ran into one problem that I cannot solve in a good way. This is the problem of falling apart fields. What I'm trying to do is skip all the paragraphs in my document and summarize the results of the .outerHeight (true) jQuery call. This should give me the full height of the element, including padding, border and border. And in fact, he does what he says, but the problem here is that he does not take into account the collapse of the fields. Because of this, I end up with the wrong overall size (larger than the real one), because the browser discards some fields (adjacent paragraphs in my case), but I take them into account.
Any ideas how to solve this problem, except for introducing an algorithm that determines which fields are collapsed and which are not? I think this is ugly ...
source share