首页 > 解决方案 > 如何在 iFrame 中包含 Bootstrap

问题描述

我目前正在做一个需要我在 iFrame 中使用 Bootstrap 的项目。我尝试将它包含在文档的头部,但它没有应用于 iFrame。我一直在尝试将 Bootstrap 链接插入 iFrame 的头部,但我无法定位它。我什至尝试将它包含两次(在包含文档和 iFrame 的头部),但它没有被应用。谁能提出一个好的方法来做到这一点?

这是我到目前为止所拥有的:index.html

    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
    </head>

    <body>
        <div class="row">
            <iframe id="iframe" class="col-lg-12 col-md-12 col-sm-12">

            <head>
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
            </head>

           </iframe>
      </div>
</body>

标签: htmlcsstwitter-bootstrapiframehead

解决方案


为什么要将 CDN 添加到正文标签?这就是带有引导程序的 iframe 的完成方式。

 <html>
    <head>
    <meta name="viewport" content="width=device-width, initialscale=1">
   <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    </head>

    <body>
    <div class="row">
        <iframe id="iframe" class="col-lg-12 col-md-12 col-sm-12"></iframe>
    </div>
       <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    </body>
   </html>


推荐阅读