2017-03-01 44 views
1

我正在使用phonegap,并且我试图根据移动设备宽度适合div内的图像,而无需拉伸。根据移动设备宽度,无需拉伸,图像适合div内部

<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> 

回答

1

img { 
    max-width: 100%; 
} 

它会阻止你的源每个IMG标记为“拉伸”超过最大屏幕宽度。

+0

谢谢唐的回复,但没有帮助我。当我将其更改为最大宽度:100%时,图像甚至不会出现。最小宽度:100%,它的确如此。 – Vicky

+0

为你的img标签加上'display:block;'结合'max-width:100%'或'display:inline-block;'不管你想要什么 – DonVitoCorleone

+0

Don,它不工作。当我给最小宽度:100%和高度:自动 - 该图像出现,但与弹力 – Vicky