【发布时间】:2017-12-05 09:02:45
【问题描述】:
我有一个显示图像的 html 页面。 当图像大于浏览器的窗口时,图像会调整大小(保持相同的比例)以适应 Firefox 的窗口。 但是在 Chrome 中,图像被压缩了
这里是html代码:
<div class="container">
<div class="auto">
<img class="full-width" src="http://laurent.delrocq.free.fr/test/img-1.jpg" />
<div class="absolute">
<img src="http://laurent.delrocq.free.fr/test/left.png" alt="#" class="left">
<img src="http://laurent.delrocq.free.fr/test/right.png" alt="#" class="right">
</div>
</div>
</div>
和css:
html, body {
height: 100%;
margin: 0;
padding: 0;
}
.container {
text-align: center;
}
.auto {
width:auto;
height:auto;
position:relative;
display:inline-block;
}
.absolute {
position:absolute;
top:0;
left:0;
height:100%;
width:100%;
z-index:2;
}
.left {
position:absolute;
top:50%;
left:15px;
transform: translateY(-50%);
}
.right {
position:absolute;
top:50%;
right:15px;
transform: translateY(-50%);
}
.full-width {
width:auto;
max-width:100%;
max-height: 100vh;
height:100%;
}
如何更改代码以使其在 Firefox 和 Chrome 上都能正常工作(调整大小)?
【问题讨论】:
标签: html css image google-chrome firefox