iframe-resizer+lit实现iframe拖动改变大小效果代码

代码语言:html

所属分类:拖放

代码描述:iframe-resizer+lit实现iframe拖动改变大小效果代码

代码标签: iframe-resizer lit iframe 拖动 改变 大小

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">
  

  
  
<style>
body {
  font-size: 14px;
  padding: 1rem;
}

p code {
  background: #f0f0f0;
}

pre {
  background: #f0f0f0;
  white-space: pre;
  overflow-y: auto;
  padding-inline: 1rem;
}
</style>


</head>

<body >
  <div>
  <h1>Resize-Inator</h1>
  <p>An iFrame resizer with a twist! It uses <code>input[type="range"]</code> under the hood for resizing. To enable automatic iFrame height-matching, you need to add <a href="https://davidjbradshaw.github.io/iframe-resizer/">iFrame Resizer</a> to your iFrame'd documents.</p>

  <pre><code>
&lt;script src="iframeResizer.contentWindow.min.js">&lt;/script>
  </code></pre>
</div>

<resize-inator class="resizable">
  <iframe title="Tri-State Area content iframe" height="300" src="https://code.bfw.wiki" frameborder="0"></iframe>
</resize-inator>

  
      <script type="module">
import { LitElement, html, css } from "https://cdn.skypack.dev/lit@2.4.0";
import iframeResize from "https://cdn.skypack.dev/iframe-resizer";

class ResizeInator extends LitElement {
  static get styles() {
    return css`
      :host {
        --thumbBackgroundColor: #f0f0f0;
        --thumbBorderColor: #767676;
        --thumbActiveBackgroundColor: lightblue;
        --thumbActiveBorderColor: blue;
        --thumbColor: currentColor;
        --thumbBorderRadius: 3px;
        --backgroundColor: #f8f8f8;

        display: block;
        max-width: 100%;
        position: relative;
        padding-right: 1.1em;
        line-height: 0;
      }

      ::slotted(iframe) {
        background: Canvas;
        z-index: 2;
        position: relative;
      }

      input[type="range"] {
        position: absolute;
        width: 100%;
        height: 100%;
        z-index: 1;
      }

      input[type="range"] {
        -webkit-appearance: none;
      }

    .........完整代码请登录后点击上方下载按钮下载查看

网友评论0