简体   繁体   English

HTML分页的两列布局

[英]HTML Paginated Two-Column layout

I have a two-column page ( <p> tags after the first half are moved to column 2 with javascript). 我有一个两列的页面(上半部分后的<p>标记使用javascript移至第2列)。

My problem is that I want to break it up into "pages" like you'd see if you were reading a PDF. 我的问题是,我想将其分解为“页面”,就像您看到的是阅读PDF一样。

Is there a neat way to do this? 有没有一种整洁的方式做到这一点? Or do I need to check if each page is overflowing programmatically as I fill them? 还是我在填满页面时是否需要检查每个页面是否以编程方式溢出 Would that even work? 那行得通吗?

在此处输入图片说明

A possible way to do it is to make all different div's with all the copy in it and then with scrollTop go to the according page/collumn. 一种可行的方法是使用所有副本创建所有不同的div,然后使用scrollTop转到相应的页面/列。

Something like: 就像是:

<div id="page1" class="page">
    <div id="p1_column_1" class="column">Here all the copy</div>
    <div id="p1_column_2" class="column">Here all the copy</div>
</div>
<div id="page2" class="page">
    <div id="p2_column_1" class="column">Here all the copy</div>
    <div id="p2_column_2" class="column">Here all the copy</div>
</div>

Then css give it a height a width and overflow hidden and then with javascript/jquery something like: 然后css给它一个高度,一个宽度,隐藏溢出,然后使用javascript / jquery之类的东西:

var curr_col = 0;
var col_height = $('.column').height();
$('.column').each(function() {
      $(this).scrollTop(col_height*curr_col);
      curr_col++;
})

Edit Check this fiddle to see the result: http://jsfiddle.net/taPjR/3/ . 编辑检查此小提琴以查看结果: http : //jsfiddle.net/taPjR/3/ In the example I copied the text with jQuery from the first div. 在示例中,我从第一个div复制了文本。

And I know it's very a dirty way, but I'm not sure if there is another keeping different fonts/font sizes and the images in the copy in mind. 而且我知道这是一种非常肮脏的方式,但是我不确定是否还有另一种方式会记住不同的字体/字体大小以及副本中的图像。

Maybe a pdf generator like LaTex ( http://www.latex-project.org/ ) could also be interesting? 像LaTex( http://www.latex-project.org/ )这样的pdf生成器也许也很有趣? Hope I could help. 希望我能帮上忙。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM