How do I specify image size so it scales to 100% width on iPhone and android browsers?

百般思念 提交于 2020-01-06 12:53:27

问题


I'm developing my first mobile site. The design is pretty simple - almost no graphics. There's a page that allows users to search for retirement communities by zip code. The search results page is just a list of communities found, with links to open an individual community page for each.

All works file, EXCEPT... the client now wants to feature an image of each community on the specific page for that community. The image needs to span the entire width of the screen, regardless of whether the user is viewing in portrait or landscape mode, and it needs to work the same way on both iPhone and android browsers.

How do I specify image size so that it works this way?

Edited to add: I do have a viewport tag already, but although it's correctly setting the size of text and HTML/css elements, it's not having any effect on the images.


回答1:


      <img src="source" width="100%" />

or

     <img src="source" style="width:100%" />

or

 <style>
  .full
  {
  width: 100%;
  }
  </style>
 <img src="source" class="full" />

should do the job;




回答2:


Try using

.img {
    max-width: 100%;
}



回答3:


Try this; It seems to work for iPhone and Blackberry – not great for android though – by adding a width and height on the body tag to the size of the image. The mobile browsers will then zoom in to the image size.



来源:https://stackoverflow.com/questions/4891031/how-do-i-specify-image-size-so-it-scales-to-100-width-on-iphone-and-android-bro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!