gpt4 book ai didi

html - Firefox CSS3 对象适合 : cover strange behaviour during transition

转载 作者:搜寻专家 更新时间:2023-10-31 08:44:14 24 4
gpt4 key购买 nike

我在 div 中有 img,具有精确的 widthheight。我想把图像放在那里,比如 background-size: cover 来填充整个 div 所以 HTML 是:

<div class="cover">
<img class=active src="http://pixabay.com/static/uploads/photo/2015/02/26/17/56/clock-650753_640.jpg" alt="time">
</div>

CSS 是:

.cover {
width: 400px;
height: 180px;
position: relative;
}

.cover img {
visibility: hidden;
opacity: 0;
width: 100%;
height: 100%;
object-fit: cover;

-webkit-transition:visibility 0s linear 4.0s,opacity 2.0s linear 2.0;
transition:visibility 0s linear 4.0s,opacity 2.0s linear 2.0s;
}

.cover img.active {
visibility: visible;
opacity: 1;
}

这是一个活生生的例子 http://jsfiddle.net/sytwrd9L/1/ - 加载图像 2 秒后消失。在 Firefox 36 中,它会在转换期间调整 img 的大小,但在其他浏览器中它运行良好。知道如何解决在 FF 过渡期间不调整 img 的大小吗?

最佳答案

我知道这是一个老问题,但今天我找到了解决这个问题的方法。到目前为止,我已经在 Firefox 44.0 中对其进行了测试。

解决方法:

<!-- Apply the transition to this element -->
<div class="transition">
<!-- Apply a 3D translate to this element -->
<div class="translate3d">
<!-- Apply object-fit to this img elemnt -->
<img src="path/to/img.jpg" class="object-fit" />
</div>
</div>

关于html - Firefox CSS3 对象适合 : cover strange behaviour during transition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28939689/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com