- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
UPDATE:
The idea behind my attempts so far has been focused on adjusting the iframe container and fixing it based on the intrinsic ratio of the Iframe so that it would then as it responds to change in proportion the contents would also change proportionally. This does not seem to work as some elements of the iframe remain fixed. I would really like to have a responsive Strava Iframe but for some reason cannot figure out to achieve this. I have made a Codepen Collection with current attempts thus far.
我最近添加了一个用于嵌入的简码 Strava iframe 到我的 Hugo 网站(学术主题)。在桌面设备上,iframe 可以正确呈现并且在浏览器中看起来是响应式的,但在移动设备上,情况并非如此。手头的问题可以看这个webpage和我的 GitHub repo .如果您能帮助我解决此问题,我将不胜感激。
我一直在尝试 Hugo 论坛和其他在线资源上推荐的多种 CSS 调整和变体。
当前简码:
{{ if and (.Get "id") (.Get "hash") }}
<div class="responsive-object">
<iframe height='405' width='590' frameborder="0" allowtransparency='true' scrolling='no' src="https://www.strava.com/activities/{{ .Get "id" }}/embed/{{ .Get "hash" }}"></iframe>
</div>
{{ end }}
当前的 CSS:
.responsive-object iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.responsive-object {
position: relative;
padding-bottom: 67.5%;
height: 0;
margin: 10px 0;
overflow: hidden;
}```
Despite trying to make the iframe container responsive, the same result occurs where it seems responsive on desktop browsers yet not on mobile devices. I am unsure of how to proceed from this point, or if I am missing something.
最佳答案
你加了<meta name="viewport" content="width=device-width, initial-scale=1.0">
吗
致您的<Head>
?
如果是,我将使用解决方案编辑我的帖子 :)
编辑
到目前为止,我发现的关于创建响应式 iframe 的最佳文章是 How To Make Responsive Iframes - It's Easy! .
三个要点:
在 iframe 开始标记中不设置任何属性,特别是 width 和 height
在 iframe 周围放置一个 div 容器,并使用 CSS height: 0;然后 padding-bottom: nn%; 为容器提供高度,以高度:宽度的百分比表示。
使用 -webkit-overflow-scrolling: touch 和 overflow: auto 将 div 样式设置为内联,这是处理移动设备上的滚动所必需的,并且在CSS。
这段代码对我有用:
//HTML(在嵌入 block 中,而不是代码块中)
<div class="iframe-container iframe-container-for-wxh-500x350" style="-webkit-overflow-scrolling: touch; overflow: auto;">
<iframe src="http://www.targetWebsiteURL.com"> <p style="font-size: 110%;"><em><strong>IFRAME: </strong> There is iframe content being displayed here but your browser version does not support iframes.</em> Please update your browser to its most recent version and try again.</p> </iframe>
</div>
//CSS
.iframe-container { position: relative; margin: 5px; height: 0; overflow: hidden; }
.iframe-container-for-wxh-500x350 {
padding: 25px 25px 70% 25px; /* padding-bottom = h/w as a % */
}
.iframe-container iframe {
position: absolute;
top: 0;
left: 0;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
border: 1px inset #7a8b8b;
/* put following styles (necessary for overflow and
scrolling handling) in div container around iframe
because not stable in CSS
-webkit-overflow-scrolling: touch;
overflow: auto; */
} 使用一个单独的类来设置 padding-bottom 的样式,这样,如果您有多个 iframe 并且它们具有不同的 wxh 比率,您所要做的就是为每个代码编写一个类并将 padding-bottom 设置为不同的百分比。
关于html - 难以使 Strava Iframe 响应式 (CSS/HTML),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56287729/
所以我知道,如果我将 iFrame 包含到不在同一域中的页面,我将无法通过浏览器策略访问该 iframe 的 DOM,但是 iframe 中的页面可以执行任何类型的父文档访问吗? 具体来说,我必须考虑
我有 3 个嵌套的 iframe,我想访问第三个 iframe 中的元素(链接)。 var iframe = document.getElementById('aswift_2'); var inne
Chrome 有最简单的方法,只需从下拉列表中选择一个框架即可。 Firefox 提供了 cd(frame)功能不太好用,但只要您愿意发现哪个框架是哪个框架就可以完成工作。 但是我们如何在 Inter
我们公司正在考虑允许第三方网站使用我们的在线结账系统。 一位客户表示,他们希望能够使用灯箱样式的弹出窗口来显示结帐。他们希望在网站的每个页面上都可以使用它,因此大多是不安全的页面。我们的结帐系统和客户
当 iframe 中加载的页面来自另一个域时,我们如何从 iframe 中加载的文档访问父文档? 我收到权限被拒绝错误。 最佳答案 如果您可以控制这两个文档,那么您可以轻松地使用 easyXDM (
使用 SOAP 调用我得到一个 URL 并在 iframe 中显示。那个 URL 内容是一个表单,用户需要填写所有数据并提交它。当我调用 SOAP 函数时,也给出了一个返回链接,其中一个重定向到我的站
我正在尝试开发一个小型 Web 应用程序,其中包含一个使用来自另一个域的 iframe 的 Web 应用程序。我正在尝试在本地计算机上对此进行测试,为此我需要模仿 iframe 来自另一个域(虽然它实
我有一个网页 指向另一个网站。我不希望这阻止页面其余部分的加载。有没有办法异步加载它? 最佳答案 使用 jQuery,可以实现以下效果: $(window).load(function() {
我搜索过高低,无法找到解决方案。在我看来,iframe API仅适用于较旧样式的网址,而不适用于较新的海关网址。 我的意思是,如果某人的YouTube网址为www.youtube.com/user/T
我想在我的网站上显示youtube视频。 iframe是可能的,我只需要像这样将其放在我的网页上。 一切都很好,除了我超过99%的客户来自伊朗,而且YouTube在伊朗被政府封锁。因此,直接从you
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
所以我有一个简单的页面,当用户单击链接时,iframe 将打开。我正在尝试使用 http://www.google.com/support/analytics/bin/answer.py?hl=en&
假设情况:我有一个名为“miniatureBoltsInCarburetors.com”的不起眼的小网站,该网站提供有关将化油器固定在一起的微型 bolt 的内容以及一些一般相关的汽车信息。我的网站还
IE 6.0 向我显示消息“此页面包含安全和非安全项目”,因为我的页面上有 iframe(针对组合框错误)。我尝试指向 src 中的一些不同的内容,但如果不放入空白的 html 页面,我似乎无法摆脱此
我有一个带有一个 iframe 和一个按钮的网页。 在页面加载事件中, if (!Page.IsPostBack) { string sDocUrl = //some doucmen url Ifra
我有一个带有一些 IFrame 的页面。这些 IFrame 位于同一域中。我想在打开模态窗口时从页面中删除 iframe 内容,以减少模态窗口中的延迟。 然后,当我关闭模态窗口时,我希望将 IFram
我正在尝试访问一个框架内的控件,该框架位于另一个框架内的框架内。 最后(最深的)框架仅用于登录 - 我设法做到了。 问题是登录后我基本上需要回到上框点击一个按钮。出于某种原因,我不断收到错误消息: N
我有下一个元素结构: .. actual markup with scripts here 使用纯 javascript,我已经摆脱
我们使用 Worldpay 作为我们的支付提供商,我们将 PayPal 作为 worldpay 的一部分实现,这意味着我们只与 Worldpay 集成,他们处理 PayPal 集成。 虽然这会带来很多
我有一个客户,由于特定原因,需要在 HTTP 页面上放置一个指向 HTTPS 页面的 IFRAME。 HTTP 页面托管在与 HTTPS 页面不同的域和服务器上,但都属于同一客户端。 撇开为什么不应该
我是一名优秀的程序员,十分优秀!