【发布时间】:2014-09-25 10:58:42
【问题描述】:
我使用的是 Chrome 并且代码工作正常,但是,当我将其加载到 Internet Explorer 中时,它会以实际大小显示图像,而不是缩放以适应屏幕。我希望图像位于页面的左侧并从上到下覆盖,而不是从左到右。我希望它保持不变,以便正确缩放图像。这就是我所拥有的。有没有更简单的方法?我正在使用 Internet Explorer 8。 预计到达时间:图片为 340x554 像素
<!DOCTYPE html>
<html>
<head>
<style>
body{
background-color:#000000;
}
#logo{
top:0;
bottom:0;
left:0;
position:absolute;
background-image:url('logo.jpg');
background-size: contain;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-repeat:no-repeat;
height:100%;
width:100%;
}
</style>
<title>Title</title>
</head>
<body>
<div id="logo">
</div>
</body>
</html>
【问题讨论】:
-
background-size: contain;不受ie8支持; caniuse.com/#feat=background-img-opts