Safari图像大小自动高度CSS [英] Safari Image Size Auto Height CSS

查看:604
本文介绍了Safari图像大小自动高度CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在最新版本的Safari for Windows 7中测试此问题。



问题是,此代码适用于所有其他浏览器>

 < style type =text / css> 
.userImg {height:100%; width:100%; }
.imgContainer {height:auto; width:150px; }
< / style>

< div class =imgContainer>
< img id =imgclass =userImgsrc =TemplateFiles / Hydrangeas.jpgalt =/>
< / div>

有没有人知道一个技巧, / p>

谢谢!

解决方案

只设置图片的宽度。浏览器将自动按比例缩放图片。

  .userImg {width:100%; } 
.imgContainer {height:auto; width:150px; }


I am testing this problem in the latest version of Safari for Windows 7.

The problem is that this code works in all other browsers BUT safari:

 <style type="text/css">
    .userImg { height: 100%; width: 100%; }
    .imgContainer { height: auto; width: 150px; }
 </style>

 <div class="imgContainer">
    <img id="img" class="userImg" src="TemplateFiles/Hydrangeas.jpg" alt="" />
 </div>

Does anyone know of a trick to get this to size the image proportionally in Safari using just CSS?

Thanks!

解决方案

Just set only the width on the image. The browser will scale the image proportionally automatically.

.userImg { width: 100%; }
.imgContainer { height: auto; width: 150px; }​

这篇关于Safari图像大小自动高度CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆