自动调整谷歌网站嵌入代码高度 (html)

问题描述

我使用 Google 协作平台嵌入 HTML 代码,将代码粘贴到“从网络嵌入”窗口中。输出的长度是可变的。

我希望有一种方法可以动态调整 Google 协作平台用来托管我的 HTML 的父级 iframe 的高度。

我知道我可以使用 Google 协作平台用户界面手动分配更多空间,但不幸的是,根据 API 数据,内容会有所不同,因此我无法事先知道高度。目前,只要内容过满分配的空间并且看起来不好看,就会出现垂直滚动条。

我尝试了以下操作,但它只删除了滚动条而不允许我看到内容

<script>parent.document.getElementsByTagName('iframe')[0].scrolling="no";</script>

示例 Google 网站位于 https://sites.google.com/view/auto-ajust-gsite-embed/home

这是我在上面的示例站点中使用的代码

<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- required Meta tags -->
    <Meta charset="utf-8" />
    <Meta name="viewport" content="width=device-width,initial-scale=1" />

    <!-- Bootstrap CSS -->
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css"
      rel="stylesheet"
      integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl"
      crossorigin="anonymous"
    />

    <title>auto adjust google site embed</title>
  </head>
  <body>
    <div class="accordion accordion-flush" id="accordionFlushExample">
      <div class="accordion-item">
        <h2 class="accordion-header" id="flush-headingOne">
          <button
            class="accordion-button collapsed"
            type="button"
            data-bs-toggle="collapse"
            data-bs-target="#flush-collapSEOne"
            aria-expanded="false"
            aria-controls="flush-collapSEOne"
          >
            Accordion Item #1
          </button>
        </h2>
        <div
          id="flush-collapSEOne"
          class="accordion-collapse collapse"
          aria-labelledby="flush-headingOne"
          data-bs-parent="#accordionFlushExample"
        >
          <div class="accordion-body">
            Placeholder content for this accordion,which is intended to
            demonstrate the <code>.accordion-flush</code> class. This is the
            first item's accordion body.
          </div>
        </div>
      </div>
      <div class="accordion-item">
        <h2 class="accordion-header" id="flush-headingTwo">
          <button
            class="accordion-button collapsed"
            type="button"
            data-bs-toggle="collapse"
            data-bs-target="#flush-collapseTwo"
            aria-expanded="false"
            aria-controls="flush-collapseTwo"
          >
            Accordion Item #2
          </button>
        </h2>
        <div
          id="flush-collapseTwo"
          class="accordion-collapse collapse"
          aria-labelledby="flush-headingTwo"
          data-bs-parent="#accordionFlushExample"
        >
          <div class="accordion-body">
            Placeholder content for this accordion,which is intended to
            demonstrate the <code>.accordion-flush</code> class. This is the
            second item's accordion body. Let's imagine this being filled with
            some actual content.
          </div>
        </div>
      </div>
    </div>
    <script
      src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js"
      integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0"
      crossorigin="anonymous"
    ></script>
  </body>
</html>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...