Iphone – Resize images in UIWebView to viewport size

imageiphoneuiwebview

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

Best Answer

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;