Reputation: 11665
I have a webview with a specific size :
let webviewwidth:CGFloat=self.view.frame.width * 0.85;
let webviewheigth:CGFloat=(self.view.frame.height - navbarHeigth) * 0.85;
myWebView = UIWebView(frame: CGRectMake(0, navbarHeigth , webviewwidth, webviewheigth));
with the content of:
<img src="myimage.jpg" width=????? alt="" border=0><br>
How can I set the size an image (?????) to the size of its webview ? When setting the width in HTML to the webviewsize, it will be to large, because the width of the webview is in points and not pixels.
Any hints ?
Upvotes: 2
Views: 93
Reputation: 24714
Here is the css I use for img in webview
img {max-width: 100%;height: auto;margin-left: auto;margin-right: auto;}
If you want every img width to be 100% just replace max-width
to width
Upvotes: 3