小编And*_* K.的帖子

如何将文本划分为单独的页面(如Google文档)?

我一直在创建一个在浏览器中运行的专用文本编辑器.我有一个让我陷入昏迷的问题.如何在Google文档中检测并将长文本分割成单独的页面?我知道谷歌文档不能通过满足,但必须有一些解决方案......

Edit1:我们需要考虑几个场景:

  1. 我们通过json对象加载文档,然后渲染我们的页面.
  2. 我们正在键入文本并到达页面末尾.
  3. 我们删除了该文本.
  4. 我们插入或删除一段文字.

谷歌博客分页 https://googleblog.blogspot.ru/2011/04/pagination-comes-to-google-docs.html

page.html中

<div class="box-base">
    <div id="page-1" class="page">
         <div id="editable-1" class="document" contenteditable="true"></div>
    </div>
    <div id="page-2" class="page">
         <div id="editable-2" class="document" contenteditable="true"></div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

styles.css的

.box-base {
    margin-left: 50px;
    flex: 1 0 430px;
    border-style: solid;
    display: -webkit-flex;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    height: 900px;
    overflow: auto;
}
.page {
    width: @page-width;
    height: @page-width * 1.414;
    /*overflow-y: auto;*/
    background: white;
    margin: 25px 0 25px 0;
}
.document {
  /*max-height: 1000px;*/
  overflow: hidden;
}
Run Code Online (Sandbox Code Playgroud)

html javascript pagination text-editor contenteditable

6
推荐指数
1
解决办法
696
查看次数

PHP。两个浮点数相减的结果

例如...

$aa = 10694994.89;
$bb = 10696193.86;
$ab = $aa - $bb;
// result is:-1198.9699999988 not the -1198,97
Run Code Online (Sandbox Code Playgroud)

但在此示例中:

$cc = 0.89;
$dd = 0.86;
$cd = $cc - $dd;
//Result is: 0.03
Run Code Online (Sandbox Code Playgroud)

为什么与示例有所不同?缺乏精度?

php subtraction floating-point-precision

5
推荐指数
1
解决办法
3289
查看次数