响应主题的响应iframe

响应主题的响应iframe,iframe,Iframe,如何使嵌入式iframe像我的网站主题一样响应?我有一个通过iframe的计算器。但即使在我放置了这个CSS之后,它也没有遵循主题响应 iframe,对象,嵌入{最大宽度:100%;} 下面是嵌入的iframe代码 <iframe style="border: currentColor; width: 375px; height: 800px; margin-top: -159px; margin-left: 410px; position: relative;" src="http://

如何使嵌入式iframe像我的网站主题一样响应?我有一个通过iframe的计算器。但即使在我放置了这个CSS之后,它也没有遵循主题响应

iframe,对象,嵌入{最大宽度:100%;}

下面是嵌入的iframe代码

<iframe style="border: currentColor; width: 375px; height: 800px; margin-top: -159px; margin-left: 410px; position: relative;" src="http://www.calculator-bmi.com/wp-content/themes/genesis-flint/js/" height="240" width="320"></iframe>

我希望你能帮我做这件事

iframe, object, embed {
    width: 100% !important;
    height: 800px !important;
    margin: 0 !important;
    border: none;
}

示例:

我参加聚会有点晚,但还是决定捐款。在保持纵横比的同时,使iframe在水平和垂直方向上都具有响应性有点棘手

您的html应该有一个iframe容器:

<div class="embed-container-noframe">
  <iframe src="http://www.calculator-bmi.com/wp-content/themes/genesis-flint/js/"></iframe>
</div>
可以通过调整容器的padding bottom属性来更改纵横比


这里有一个jsfiddle可供使用:

这是我的解决方案>>iframe+jquery,工作起来很有魅力。jsfiddle>>


html正文{宽度:100%;高度:100%;填充:0px;边距:0px;溢出:隐藏;字体系列:arial;字体大小:10px;颜色:#6e6e6e;背景色:#000;}预览框{宽度:100%;背景色:#fff;}
var calcHeight=函数(){
$('#预览帧').height($(窗口).height());
}
$(文档).ready(函数(){
calcHeight();
}); 
$(窗口)。调整大小(函数(){
calcHeight();
}).load(函数(){
calcHeight();
});
.embed-container-noframe {
  height: 0;
  width: 100%;
  padding-bottom: 70%;
  overflow: hidden;
  position: relative;
}

.embed-container-noframe iframe {
  width: 100%;
  height: 100%;
}
<html lang="en" class="no-js">
   <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1.0">
      <style>
      html body {width: 100%;height: 100%;padding: 0px;margin: 0px;overflow: hidden;font-family: arial;font-size: 10px;color: #6e6e6e;background-color: #000;} #preview-frame {width: 100%;background-color: #fff;}</style>
      <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
      <script>
         var calcHeight = function() {
           $('#preview-frame').height($(window).height());
         }

         $(document).ready(function() {
           calcHeight();
         }); 

         $(window).resize(function() {
           calcHeight();
         }).load(function() {
           calcHeight();
         });
      </script>
   </head>
   <body>
      <iframe id="preview-frame" src="http://yourwebsitehere.com/" name="preview-frame" frameborder="0" noresize="noresize">
      </iframe>
   </body>
</html>