Resize images in UIWebView to viewport size

风流意气都作罢 提交于 2019-11-28 23:04:44

问题


I'm displaying HTML with some images inside a UIWebView in my iPhone App. When the images are wider than the viewport of the iPhone I get horizontal scrollers which I don't want because its mostly about the text not the images.

Is there a way to resize images displayed inside the UIWebView according to the width (best: even if the device is rotated)?


回答1:


If you want the maximum width to be the width of the webView, use the max-width CSS property.

max-width: 100%; width: auto; height: auto;




回答2:


If the image is inside a UIWebView you could try using css to size them to 100%?

Something like . . .

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

DISCLAIMER: I don't have XCode handy to test that but it should work! You'll have to try it for yourself!



来源:https://stackoverflow.com/questions/2676279/resize-images-in-uiwebview-to-viewport-size

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