0

我正在尝试更改 OneNote div 的绝对位置但没有成功。我可以使用绝对定位的 div 创建全身:

这是我的要求:

[
   {
    'target':'body',
    'action':'replace',
    'content':'<body data-absolute-enabled="true">
    <p>This content will appear in the _default div.</p>
    <div style="position:absolute;top:175px;left:100px" data-id="div1">
      <p>This content will appear in an absolute positioned div.</p>
    </div>
    <div>
        <p>This content will also appear in the _default div.</p>
    </div>
</body>'
  }
]

这是输出html(没关系):

<html>

<head>
    <title>x2222x</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="created" content="2021-04-18T09:13:00.0000000" />
</head>

<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
    <div id="div:{f3e8317f-4b34-00f5-3826-a7b41de83075}{18}" style="position:absolute;left:48px;top:91px;width:624px">
        <p id="p:{ef5cb98c-74e7-4c65-b51a-0adbc66d9c97}{225}" lang="en-US" style="margin-top:5.5pt;margin-bottom:5.5pt">
            This content will appear in the _default div.</p>
        <p id="p:{ef5cb98c-74e7-4c65-b51a-0adbc66d9c97}{228}" lang="en-US" style="margin-top:5.5pt;margin-bottom:5.5pt">
            This content will also appear in the _default div.</p>
    </div>
    <div id="div:{ef5cb98c-74e7-4c65-b51a-0adbc66d9c97}{229}" data-id="div1"
        style="position:absolute;left:99px;top:174px;width:624px">
        <p id="p:{ef5cb98c-74e7-4c65-b51a-0adbc66d9c97}{233}" lang="en-US" style="margin-top:5.5pt;margin-bottom:5.5pt">
            This content will appear in an absolute positioned div.</p>
    </div>
</body>

</html>

OneNote 页面

但是,我不能改变这个位置,我需要“移动” div1。如何将绝对位置更改为特定的 div?

这是我“移动” div1(按 id)的请求,但它不起作用:

PACH https://graph.microsoft.com/v1.0/me/onenote/pages/{my_page_id}/content
[
   {
    'target':'div:{ef5cb98c-74e7-4c65-b51a-0adbc66d9c97}{229}',
    'action':'replace',
    'content':'<div style="position:absolute;top:350px;left:200px" data-id="div1">
      <p>This content will appear in an absolute positioned div (updated).</p>
    </div>'
  }
]

谢谢!!!

4

1 回答 1

0

查看相关文档页面绝对定位的 div 不能简单地替换,它们必须是 body 元素的直接子元素。
因此,实现您正在寻找的结果的唯一方法是更换整个身体。

于 2021-07-08T13:08:25.300 回答