html - 为什么图像的最大高度适用于除 Firefox 以外的所有浏览器?

标签 html css firefox layout

看看这个 fiddle :http://jsfiddle.net/2fhbjszn/4/

它在 chrome 和 safari 中工作正常,只有 firefox 计算高度错误导致幻灯片不适合容器。

我正在尝试在绝对定位的容器内创建一组 float 的左侧幻灯片,但它看起来像 firefox 将幻灯片的高度延伸到容器高度之外,就像没有给出 max-height: 100% 指令一样。

这是我的 html:

<div class="wrapper">
    <div class="absolute-container">
        <div class="slides">
            <div class="slide">
                <img src="https://unsplash.com/photos/WLUHO9A_xik/download"/>
            </div>
            <div class="slide">
                <img src="https://unsplash.com/photos/pYxh7-ITaq8/download"/>
            </div>
        </div>
    </div>
</div>

这是我的 CSS:

.wrapper {
    width: 900px; 
    height: 250px; 
    background-color:#aaa; 
    position:relative;    

    .absolute-container {
        position: absolute; 
        top: 30px; 
        bottom: 30px; 
        background-color: #DBD9C7; 
        width: 100%;
        height: 100%;
    }
}
.slides {
    height: 100%;
    &:after {
        content: "";
        display: table;
        clear: both;
    }
}

.slide {
    float:left; 
    height: 100%;
    margin-right: 5px;
    img {
        max-height: 100%; 
        max-width: 100%; 
        width: auto; 
        display:block;
    }
}

最佳答案

看起来像是 Firefox 中试图计算 <div class="slide"> 的错误宽度,因为目前它是在重新缩放之前计算为原始图片的宽度。也就是说,快速解决方法是设置 max-height:在图像上以像素为单位而不是相对。

关于html - 为什么图像的最大高度适用于除 Firefox 以外的所有浏览器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27116543/

相关文章:

Angular 6 - 在 ngx-sortable 控件中放置一个动态表单

javascript - window.webkitNotifications.requestPermission 在其他计算机上不起作用

html - 将底部边框放在页面右上角 Logo 下方的 CSS 问题

javascript - 将从网站加载的 Javascript 文件的执行替换为我自己的

css - 手动更改 Bootstrap.css 中的容器宽度是否足够?

javascript - D3 图表图像下载在 Firefox 中不起作用

html - 我们如何定位从图像 Sprite 获得的图像?

html - 在同一行上获取 Twitter 推文和 Facebook 点赞

javascript - google.maps.event.addDomListener mousedown 在 Firefox 上

JavaScript 仅适用于 Firefox