简体   繁体   English

Internet Explorer 9 - 按比例调整图像大小

[英]Internet Explorer 9 - Resize image proportionally

I'm trying to limit image width with CSS only: 我只想用CSS限制图像宽度:

#lateral-derecho #patrocinadores img
{
    max-width: 130px;
    height: auto;
    margin: 0 auto;
}

And every browser is doing it all right except IE 9. It's not doing it proportionally. 除了IE 9之外,每个浏览器都可以正常运行。它没有按比例执行。 I'm running it in <meta http-equiv="X-UA-Compatible" content="IE=8" /> . 我在<meta http-equiv="X-UA-Compatible" content="IE=8" />

BTW, IE 9 in standards mode does not even understand margin: 0 auto; BTW,IE 9在标准模式下甚至不了解margin: 0 auto; or I'm doing something wrong? 或者我做错了什么? they did a crappy browser again? 他们又做了一个糟糕的浏览器?

Edit: this is all the CSS, container (#patrocinadores) and img, img is contained inside #patrocinadores > a > img : 编辑:这是所有的CSS,容器(#patrocinadores)和img,img包含在#patrocinadores > a > img

#lateral-derecho #patrocinadores
{
    float: right;
    width: 136px; 
    margin-top: 25px;
    padding: 15px 0 5px;
    background: url(images/top-patrocinadores.png) top no-repeat #eee;
    text-align: center;
}

#lateral-derecho #patrocinadores a{display: block;}
#lateral-derecho #patrocinadores img
{
    max-width: 130px;
    height: auto;
    margin: 0 auto;
}

Try this: 尝试这个:

#lateral-derecho #patrocinadores a {
    display: block;
    max-width: 130px;
}
#lateral-derecho #patrocinadores img {
    max-width: 100%;
}

If you want good quality scaling for IE < 9, you'll want to include the AlphaImageLoader and set sizingMethod to scale . 如果你想要IE <9的高质量缩放,你需要包含AlphaImageLoader并设置sizingMethodscale

Get rid of the height: auto; 摆脱height: auto; . You don't need it, and it's the cause of the problems. 你不需要它,这是问题的原因。

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

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