Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (webview)
Viewing all articles
Browse latest Browse all 680

WebView large font size issue on iPhone 5

$
0
0

Hi there,

I use WebView to display html content locally using setHtml() and it works perfectly fine on iphone 6/6+ devices. However when it comes to iphone 5, there is a very frustrating problem that sometimes the WebView shows up ok, but then most of the times, the css styling does not apply well that it makes the font size too big for the body content. (With the same web page, sometimes its ok, but then sometimes its fonts ize gets really big)

Not sure if anyone has had this problem? I would much appreciate if someone can help me with this? Thanks in advance

Below is what I did for the html content with details are passed from the 'args' variable:

var style = "<html><head> <style> body { font-family: "+ Alloy.Globals.Fonts.Regular +"; font-weight: 400; line-height: 1.42857143; font-size: "+ Alloy.Globals.FontSize.web +" !important; color: #333333; background-color: #fff; text-align: center; }

                    .container {
                        margin-right: auto;
                        margin-left: auto;
                    }

                    #main {
                        padding: 0 8px;
                        margin-bottom: 30px;
                    }

                    #article-content {
                        overflow-x: hidden !important;
                        background-color: white !important;
                        margin-top: 70px !important;
                    }

                    .page-header {
                        font-family: &quot;+ Alloy.Globals.Fonts.Vani +&quot;;
                        font-size: &quot;+ Alloy.Globals.FontSize.webHeader +&quot;;
                        padding-bottom: 0px;
                        margin-top: 20px;
                        margin-bottom: 0px;
                        text-align: left;
                    }

                    .article-body {
                        padding: 10px 0 50px 0;
                        font-family: &quot;+ Alloy.Globals.Fonts.ArticleContent +&quot; !important;
                        font-weight: normal !important;
                        font-size: &quot;+ Alloy.Globals.FontSize.web +&quot; !important;
                        text-align: left;
                    }

                    .article-body div,
                    .article-body p,
                    .article-body span{
                        font-family: &quot;+ Alloy.Globals.Fonts.ArticleContent +&quot; !important;
                        font-weight: normal !important;
                        font-size: &quot;+ Alloy.Globals.FontSize.web +&quot; !important;
                        line-height: 1.6 !important;
                        margin-bottom: 1.5em !important;
                        margin: 0 0 10px !important;
                    }

                    #article-content .article-body p {
                        line-height: 1.6;
                        margin-bottom: 1.5em;
                        margin: 0 0 10px;
                    }

                    .article-body h2 {
                        font-size: &quot;+ Alloy.Globals.FontSize.web +&quot; !important;
                    }

                    .article-body ul{
                        line-height: 1.5625em !important;
                        color: #262626 !important;
                        padding: 0 10px !important;
                    }

                    .article-body ul li {
                        margin-left: 0 !important;
                        margin-left: 1em !important;
                    }

                    .article-body ul li a {  
                        color: #000 !important;
                        border-bottom: 1px dotted !important;
                    }

                    .article-body img {
                        margin: 0 auto !important;
                        width: 100% !important;
                        max-width: 100% !important;
                        height: auto !important;
                        display: block !important;
                        vertical-align: middle !important;
                    } 

                    figure {
                        margin: 0 0px 20px 0px;
                        margin-top: 0px;
                        margin-right: 0px;
                        margin-bottom: 20px;
                        margin-left: 0px;
                    }

                    figcaption {
                        color: #666;
                        padding: .75em 0;
                        border-bottom: 1px solid #ecf0f1;
                        font-size: &quot;+ Alloy.Globals.FontSize.webCaption +&quot;;                           
                    }

                    a {
                        color: #337ab7;
                        text-decoration: none;
                    }

                    video {
                        width : 100%;
                    }

                    iframe {
                        width : 100%;
                    }

                &lt;/style&gt;
            &lt;/head&gt;&quot;

var body =  &quot;&lt;body&gt;
                &lt;div class=\&quot;container\&quot; id=\&quot;main\&quot;&gt;
                    &lt;section class=\&quot;clearfix\&quot; id=\&quot;article-content\&quot;&gt;
                        &lt;h1 class=\&quot;page-header headline\&quot;&gt;&quot;+ args.title + &quot;&lt;/h1&gt;
                        &lt;div class=\&quot;article-body\&quot;&gt;&quot;+ args.content + &quot;&lt;/div&gt;
                    &lt;/section&gt;
                &lt;/div&gt;
            &lt;/body&gt;&lt;/html&gt;&quot;;
return style + body;

Viewing all articles
Browse latest Browse all 680

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>