I am working on an app in which I am using UIWebView
. To make UIWebView
editable, I have used an HTML file and have set its attribute contenteditable=true
. To perform some operation, I am using JavaScript.
I have set css in HTML file. Below is the code.
<style>
#test
{
padding-left:5px;
padding-right:5px;
background-color:green;
text-align:left;
width:100%;
font-family: "Times New Roman";
border-radius:5px;
}
</style>
Now, my problem is I am getting a white margin of about 10-15px from top, bottom and left side
between UIWebView
and HTML file loaded in UIWebView
.
Here I am attaching screenshot for same.
I have just started working on HTML and JavaScript(no prior knowledge) and not getting where the problem is.
As discussed use
This will take HTML file to top left of webview.
Basically, all browsers add in that whitespace around the edges of the page to be backwards-compatible with like Netscape 1. In the HTML you're loading into the web view, you can use CSS to remove that:
If you're not loading HTML into your web view, but just the direct URL for an image file, I suggest either a) wrapping that in some basic HTML (head, body, an img tag), or b) downloading the image yourself (say with NSURLConnection), and displaying it directly in a UIImageView.