html电子书分页,HTML的书像分页

这篇文章分享了解决网页内容按页展示,类似HTMLbook的分页方法,通过JavaScript动态调整列数和页面大小,适用于iOS WebKit,Android可能不适用,值得一试。

hpique提出了一个问题:HTML book-like pagination,或许与您遇到的问题类似。

回答者Engin Kurutepe给出了该问题的处理方式:

Building on Dan's answer here is my solution for this problem, with which I was struggling myself until just now. (this JS works on iOS Webkit, no guarantees for android, but please let me know the results)

var desiredHeight;

var desiredWidth;

var bodyID = document.getElementsByTagName('body')[0];

totalHeight = bodyID.offsetHeight;

pageCount = Math.floor(totalHeight/desiredHeight) + 1;

bodyID.style.padding = 10; //(optional) prevents clipped letters around the edges

bodyID.style.width = desiredWidth * pageCount;

bodyID.style.height = desiredHeight;

bodyID.style.WebkitColumnCount = pageCount;

Hope this helps...

希望本文对你有帮助,欢迎支持JavaScript中文网

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值