简体   繁体   English

Chrome图像不透明度在宽度上的过渡使用百分比会导致尺寸调整

[英]Chrome image opacity transition on width using percent cause resize flikering

Here's the html simplified sample 这是html简化示例

<div class="big">
    <a href=".....">
        <img src=".....">
    </a>
</div>

css CSS

.big {
    width: 33.3333%;
}
img:hover {
    opacity: 0.9;
    transition: opacity 0.4s;
}

When I hover above img, the opacity transition works fine, but the image flickering on span 0.4s, it's like resizing, like the Chrome recalculate the percentage size again within 0.4s. 当我将鼠标悬停在img上方时,不透明度过渡效果很好,但是图像在跨度为0.4s时闪烁,就像调整大小一样,就像Chrome在0.4s内重新计算百分比大小一样。

Tried webkit transition, not fixing anything. 尝试过Webkit过渡,未解决任何问题。 Transition all, still happening. 过渡所有,仍在发生。

This problem only happen on Chrome, no problem at all on Firefox. 此问题仅在Chrome上发生,而在Firefox上则完全没有问题。 Only happen when using percentage, with fixed width works fine, but I need to use percentage on this one. 仅在使用固定宽度的百分比时会发生,但我需要在此百分比上使用百分比。

Thanks for any help 谢谢你的帮助

You can try this: 您可以尝试以下方法:

a {display: block }
a img {transition: opacity 0.4s; max-width: 100%;}
a:hover img {opacity: 0.9}

This is what fixed it for me: max-width: calc(100% - 1px); 这就是为我解决的问题: max-width: calc(100% - 1px);

max-height I could leave at 100%; 我可以离开的最大高度为100%; even though it was the height that was changing. 即使是高度在变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM