Javascript 根据移动设备宽度,图像适合div内部,无需拉伸
我正在使用phonegap,并且我正在尝试根据移动设备的宽度来调整div内的图像,而不进行拉伸Javascript 根据移动设备宽度,图像适合div内部,无需拉伸,javascript,css,cordova,phonegap-plugins,Javascript,Css,Cordova,Phonegap Plugins,我正在使用phonegap,并且我正在尝试根据移动设备的宽度来调整div内的图像,而不进行拉伸 <div style="padding:0px!important;overflow:hidden;margin-top: 10px;"> <center> <!-- <img src="images/user.png" id="ReguserProfileImage
<div style="padding:0px!important;overflow:hidden;margin-top: 10px;">
<center>
<!-- <img src="images/user.png" id="ReguserProfileImage" class="profileimage" style="width:120px;height:121px;" data-bind="attr: { src: image }" />-->
<img id="customerProfileImage" src="images/user.png" style="min-width:100%;height:auto" /><br />
<div class="activity-photo-upload">
<label for="profile-activity-photo">
<a id="OpenView" data-rel="actionsheet" data-role="button" href="#RegProfilePhotoPopUp" style="text-decoration: none;border:none;">
<img src="images/icon-photo.png" class="icon" />
</a>
</label>
</div>
</center>
</div>
Put
它将阻止源中的每个img标记“拉伸”超过最大屏幕宽度。谢谢Don的回复,但这对我没有帮助。当我将其更改为最大宽度:100%时,图像甚至不会显示。最小宽度为100%时,确实如此。添加
display:block代码>与最大宽度:100%
或显示:内联块组合使用,用于您的img标签不管你想要什么,它都不起作用。当我给出min width:100%和height:auto时,该图像会出现,但带有stretchDo,您碰巧有这个问题的实例,因为当我使用max width:100%尝试此代码时代码>它像一个符咒一样工作,没有拉伸,图像正常显示。
img {
max-width: 100%;
}