html - 为什么 Chrome 和 IE 显示的横幅尺寸与 Firefox 不同?

标签 html css google-chrome internet-explorer flexbox

我已经完成了一个网站(设计时使用 Firefox 作为默认浏览器),但是在不同的浏览器中进行测试时,我发现网站的滑动横幅部分在 Chrome 或 IE 中显示不正确。

不仅如此,我用来滑动图像的关键帧导致一半的图像被移出屏幕。虽然我认为这可能更多地与幻灯片容器的实际尺寸调整有关?

这是我的代码,适用于横幅部分:

#homepage-banner {
    width: 100%;
    position: relative;
    justify-content: space-around;
    height: 82vh;
    overflow: hidden;
}

.homepage-slider img {
    display: inline-block;
    cursor: pointer;
}

.homepage-slider {
    top: 3.5em;
    width: 500%;
    position: absolute;
    display: flex;
    animation: 24s slider infinite;
}

.homepage-slider:hover {
    animation-play-state: paused;
}

@keyframes slider {
    0%, {
        left: 0%;
    }

    23% {
        left: 0%;
    }

    25% {
        left: -100%;
    }

    48% {
        left: -100%;
    }

    50% {
        left: -200%;
    }

    73% {
        left: -200%
    }

    75% {
        left: -300%;
    }

    98% {
        left: -300%;
    }

    100% {
        left: -400%;
    }
}
<section id="homepage-banner">

    <div class="homepage-slider">
        <img class="freezeslideshow" id="slideImageOne" src="images/hero-banner/mfprotein.jpg" alt="Protein Deals" />
        <img class="freezeslideshow" id="slideImageTwo" src="images/hero-banner/plant-protein.jpg" alt="Protein Deals" />
        <img class="freezeslideshow" id="slideImageThree" src="images/hero-banner/image5.jpg" alt="Protein Deals" />
        <img class="freezeslideshow" id="slideImageFour" src="images/hero-banner/imaged3.jpg" alt="Protein Deals" />
        <img class="freezeslideshow" id="slideImageFive" src="images/hero-banner/mfprotein.jpg" alt="Protein Deals" />
    </div>

</section>

This is what it looks like in Firefox This is what it looks like in Chrome and IE (as you can see the images within the container are being chopped off

第一个屏幕截图显示的是 Firefox 显示的内容,第二个屏幕截图显示的是 Chrome 和 IE 显示的内容。

我通常如何处理这些前缀?我什至通过认为它与前缀有关来做出正确的假设吗?

最佳答案

您能否尝试将以下 CSS 添加到您的 img 中:max-width: 100%

关于html - 为什么 Chrome 和 IE 显示的横幅尺寸与 Firefox 不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54184838/

相关文章:

jquery - 条形图渐变背景未显示 - Highcharts

javascript - AJAX 加载内容后滚动条不起作用

javascript - 动态更改关键帧 CSS Firefox

html - 在angularjs的下拉列表中突出显示选定的值

javascript - Chrome Extension Content Script - 使用 JavaScript 抓取 YouTube 视频标题

google-chrome - 在端口 3000 上运行的 Chrome 服务 worker 进程?

javascript - 从 Chrome 书签更改文本输入

css - 如何让两个div共享剩余的宽度?

css - 带有 CSS 的宇宙飞船菜单

javascript - 在 IE 中将图像对齐到按钮的中心