- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面的 slide
类元素应保持固定的宽高比,由 CSS 中的 padding-bottom:44%;
控制。内部元素(具有 slide
类的图像)应在缩放到 100% 宽度时裁剪以适合框。
现在我的问题是,这在 Chrome、Safari、甚至 IE 中都可以正常工作,但在 Firefox 中它根本不会显示。这是为什么?
我的 HTML:
<header class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
<img class="slide" src="https://cranmoremtlodge.files.wordpress.com/2008/09/fall-foliage-003.jpg" />
</div>
</header>
我的 CSS:
/*these two are mine*/
.swiper-slide {
width: 1664px; /*assigned as element style by swiper*/
position:relative;
padding-bottom:44%;
overflow: hidden;
}
.swiper-slide .slide {
position:absolute;
top:-50%; bottom:-50%;
margin:auto;
width: 100%;
height: auto;
background: teal;
}
/*these three come with www.idangero.us/swiper/ */
.swiper-wrapper {
box-sizing: content-box;
display: flex;
height: 100%;
position: relative;
transition-property: transform;
width: 100%;
z-index: 1;
}
.swiper-container {
margin: 0 auto;
overflow: hidden;
position: relative;
z-index: 1;
}
.swiper-slide {
flex-shrink: 0;
height: 100%;
}
fiddle :https://jsfiddle.net/smauo1wu/5/
最佳答案
您的代码中发生了很多事情,其中一些导致了问题。
例如,您没有遵守 CSS rule for percentage heights .此外,您在 .swiper-slide .slide
中的绝对定位似乎不是必需的,并且在调整大小时将您的图像推离屏幕(当其他问题已解决时)。
无论如何,这里有一些修改后的代码可能会对您有所帮助。该图像现在会在所有浏览器中显示和缩放(已在 Chrome、FF 和 IE11 中测试)。
HTML(无变化)
修改后的 CSS
html, body { height: 100%; } /* NEW */
.swiper-container {
margin: 0 auto;
overflow: hidden;
position: relative;
z-index: 1;
height: 100%; /* NEW */
}
.swiper-wrapper {
box-sizing: content-box;
display: flex;
height: 100%;
position: relative;
transition-property: transform;
width: 100%;
z-index: 1;
}
.swiper-slide {
width: 1664px;
position:relative;
padding-bottom:44%;
overflow: hidden;
height: 100%; /* NEW */
width: 100%;
}
.swiper-slide .slide {
width: 100%;
height: auto;
background: teal;
}
关于html - 在 IE、Chrome、Safari 中显示时在 Firefox 中具有绝对位置的 IMG 不可见 - 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34190754/
我编写了具有几个日志函数的日志帮助程序类。在 DEBUG 模式下一切正常。但是当我在 Release模式下运行我的代码时,它崩溃了。下面是代码片段: + (void)info:(NSString *)
在用 Python 编程时,如何使 VSCode 中的格式化程序使用制表符而不是空格进行缩进?我已经将 VSCode 设置为使用制表符,但是 Python 的格式化程序忽略了这一点并且只做它自己的事情
最初我的 mongod 进程运行良好。我发现我的虚拟机上有空间紧缩,所以删除了 2 个较旧的 oplog 文件以释放空间。然后接下来我启动 mongod 并开始出现错误。然后我尝试在本地数据库中修复我
CUDA 中的内核启动通常是异步的,这(据我了解)意味着一旦 CUDA 内核启动,控制权立即返回给 CPU。当 GPU 忙于数字运算时,CPU 继续做一些有用的工作除非使用 cudaThreadsyn
在 Angular View 之间链接时,是否有一种简单的方法可以保留查询参数? 当我使用 ngHref 时,查询参数丢失: Other page 我从这个网址导航 http://localhost/
nntp(新闻)打开错误:“>> 新闻/nntp 名称或服务未知)”。 我正在运行 ubuntu 最佳答案 Gnus 要求您配置要使用的新闻服务器,并且我认为它默认为“新闻”,它在您的本地搜索域中不存
有没有一种方法可以使 vim 突出显示具有给定颜色的制表符,但仅限于 expandtab选项设置了吗?我知道 'listchars' ,但我希望能够区分“有效标签”和“无效标签”。 最佳答案 您可以添
我对 Pandoc 比较陌生,我正在尝试用我的出版物生成一个 HTML 文件以放在我的网站上。我希望首先按年份对出版物列表进行编号和组织,最新的排在最前面,最早的排在最后。 我可以使用正确的 csl
根据 this question和我读过的文档,Spark Streaming 的 foreachRDD(someFunction) 将让 someFunction 本身仅在驱动程序进程中执行,但如果
我使用 stat_summary 从我的数据创建了多个条形图。但是,我想手动指定误差线的限制(而不是使用 mean_cl_boot)。对于使用 facet_grid 绘制的数据,如何做到这一点? 我用
我在 Ubuntu 下的 Bash 中运行 R。有没有办法在运行 R 时在 Bash 中使用颜色语法高亮显示?我将非常感谢有关该主题的任何信息,并希望这个问题不会令人讨厌。 最佳答案 您可以试试 co
在我的 Symfony2 应用程序中,我设置了防火墙,以便 /admin 下的所有内容路由需要通过 https 运行,但是在部署时我得到一个重定向循环。我已经阅读了 Symfony2 网站上关于防火墙
我在查询中给出了以下代码。 where to_date(cal_wid,'yyyymmdd') between add_months(to_date(sysdate, 'MM-YYY
我有一个动态 NSTableView,它可以根据提供的数据添加许多列。对于每一列,我将标题单元格设置为 NSPopUpButtonCell。 (旁注:我必须为 NSTableHeaderView 使用
我正在尝试创建一个嵌套列表。当点击时应将无序列表附加到 被点击了。 点击第一个后我的代码失败并且不会将列表附加到新插入的 。我想将无序列表添加到任何 就在列表中。 这是一个 fiddle :http
在 MyActivity 中,我正在尝试登录后端服务器。这是我尝试过的: myViewModel = new ViewModelProvider(this, factory).get(MyViewMo
有没有办法在打印 html 时在 javascript 中添加新行?这样打印出来的html是缩进的。 document.getElementById("id").innerHTML = "hello"
我正在使用 glDrawElements 绘制三角形网格,并且希望能够使用鼠标单击来拾取/选择三角形。三角形的网格可以很大。 在固定功能 OpenGL 中,可以使用 GL_SELECT: http:/
下面的可重现数据包含每个动物(猫和狗)在每个季节(夏季和冬季)的两个协变量(cov1 和 cov2)及其各自的误差估计值 (SE) 的 50 个观察值。 library(ggplot2); libra
我有多个按钮,每个按钮都有相关文本,当用户单击按钮时,文本应根据按钮更改,并且文本应显示在 DIV 中。 我使用 if elseif 在每个按钮的文本之间进行选择,现在我无法通过该函数将文本传递给 d
我是一名优秀的程序员,十分优秀!