How to read HTML Text from JSON file - reactjs

I am unable to read the HTML tags used in content of JSON file in my react app..
The JSON file :
[{
"_id": 9,
"title":"Text 9",
"subheader":"Dummy header 9",
"images": "images/four-1.png",
"imagesmob" : "images/four-1.webp",
"content":"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent nec velit consectetur, pretium risus vel, eleifend tortor. Integer enim nulla, iaculis sit amet leo vel, sagittis maximus leo. Aliquam semper sapien bibendum nulla consectetur, ut eleifend arcu accumsan. Duis consequat diam sed dolor convallis semper. Ut justo mauris, accumsan non tempus ut, ultrices at tellus. Quisque a sapien urna. Maecenas tempor consequat sollicitudin. Nullam volutpat a eros sit amet vestibulum. Cras sollicitudin vitae urna nec varius. Etiam nec facilisis urna.</p> <p>Donec ut dui condimentum, tincidunt tellus vitae, interdum lorem. Phasellus eget pretium enim. Morbi accumsan turpis vitae turpis venenatis ullamcorper. Proin pretium nisi nec nulla faucibus, a hendrerit turpis malesuada. Nullam id faucibus metus, id faucibus metus. Donec et massa suscipit, congue tortor non, ultricies turpis. Aliquam venenatis massa velit, id ornare ante efficitur vitae. Vivamus id dui tortor. Pellentesque sem mi, bibendum a orci hendrerit, mollis eleifend eros. Nunc sodales orci purus. Vivamus molestie porta egestas. <p>Suspendisse convallis mi ullamcorper, dapibus nisi a, semper felis. Praesent ut lacus eu neque vestibulum efficitur.<\/p> Sed dolor magna, mattis a ultricies vel, <b>tincidunt<\/b> eget enim.<\/p>"
}
]
The react file
<Card variant="outlined" sx={{ maxWidth:345, borderRadius: '11px' }} elevation={3}>
<CardMedia
component="img"
height="194"
image={welcom.images}
alt="Home Page"
/>
<CardHeader
titleTypographyProps={{fontSize: 18, fontWeight: 'bold', color: 'purple' }}
title = {welcom.title}
subheader = {welcom.subheader}
/>
<CardContent>
<div>{welcom.content}</div>
</CardContent>
</Card>
In this when I am trying to read content from the json file , i am unable to get the text which is bold or paragraphs are also not coming. Any help.

You cannot render the raw html in React. For that you can use the dangerouslySetInnerHTML attribute, but you should be careful before using this attribute. As per reactjs document,
dangerouslySetInnerHTML is React’s replacement for using innerHTML in the browser DOM. In general, setting HTML from code is risky because it’s easy to inadvertently expose your users to a cross-site scripting (XSS) attack. So, you can set HTML directly from React, but you have to type out dangerouslySetInnerHTML and pass an object with a __html key, to remind yourself that it’s dangerous.
I have created based on your code.

Related

Dynamic height based on content in scrollview

I currently have two views for an app, "about" and "work." Both pages are in a horizontal scroll view that snaps to feel like a page.
The only problem is when there is a lot of content on one page the other page stretches to be as large which causes there to be a lot of blank space at the bottom.
Here is an example of what I'm talking about.
"About" and "Work Pages
<scrollview>
<View>
//small content
</View>
<View>
//large content
</View>
</scrollview>
You need to wrap the content of each page with a div that has the same height.
.horizontal-pages {
width: 300px;
max-height: 400px;
display: flex;
flex-direction: column;
}
.page-slider {
display: flex;
flex: auto;
overflow: hidden;
}
.page-wrapper {
width: 100%;
height 100%;
overflow: auto;
}
<body>
<section class="horizontal-pages">
<div class="page-header">
page header
</div>
<div class="page-slider">
<div class="page-wrapper">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam nisi sem, congue eu diam sit amet, malesuada commodo elit. Ut semper ante id lacus faucibus luctus. Mauris vitae turpis et quam blandit eleifend. Nam laoreet lacus vel egestas molestie. Pellentesque vulputate lacus id orci rutrum dapibus. Proin maximus ligula sit amet justo fringilla volutpat. Integer porta posuere tempus. Aliquam semper blandit est in faucibus.</p>
<p>Morbi vel metus lorem. Aliquam sapien massa, tempus in vehicula eu, sodales vitae magna. Sed vel rhoncus purus, tristique egestas nisi. Sed cursus nulla elit, nec malesuada augue facilisis sit amet. Morbi placerat euismod magna sit amet euismod. Duis quis feugiat massa, quis scelerisque mi. Curabitur eu quam pretium, auctor metus posuere, bibendum libero. Donec eu diam lectus. Sed pellentesque porttitor leo. Curabitur iaculis neque vel dignissim finibus. Vestibulum placerat sollicitudin dictum. Donec dignissim pharetra leo et finibus. Curabitur venenatis ligula a elit laoreet, id facilisis augue ultricies.</p>
<p>Aliquam volutpat enim quis ante vehicula faucibus. Fusce aliquet laoreet malesuada. Morbi tristique nibh sit amet nunc posuere, non facilisis velit venenatis. Aliquam id finibus elit, vitae auctor metus. Ut mollis ex vitae metus placerat condimentum. Donec consequat dapibus accumsan. Nullam mollis dui odio, et pharetra urna auctor non.</p>
<p>Sed sed tellus eu nunc scelerisque mattis. Suspendisse leo dui, congue vitae euismod quis, iaculis et enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. In ac condimentum ex. Curabitur tristique velit purus, eget tempus tortor posuere sodales. Nullam vestibulum felis id quam ullamcorper pharetra. Nunc at ultricies purus. Maecenas molestie magna id faucibus lacinia. Vivamus consequat gravida eros, nec pharetra turpis interdum iaculis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nam feugiat mauris arcu, vel auctor eros faucibus at. Aliquam tincidunt est non arcu sodales aliquet.</p>
<p>Donec tristique tempor sapien vel vestibulum. Nulla eleifend gravida congue. Donec feugiat arcu sit amet odio posuere, eu lacinia ex iaculis. Fusce a mollis ligula. Donec varius, purus in gravida iaculis, est risus posuere ante, quis tincidunt purus velit sodales ante. Ut ut nulla ligula. Cras enim neque, feugiat dignissim urna pretium, cursus condimentum justo. Praesent mauris quam, vehicula at sem id, sodales consectetur tellus. Suspendisse quis magna rhoncus, dapibus ipsum vel, vulputate lacus. Fusce molestie dui neque, eu iaculis augue porta in. In faucibus interdum massa, et tempor lorem imperdiet a. Aenean sed nulla porttitor, maximus massa eget, pulvinar orci. Suspendisse non volutpat leo, in feugiat dui. Vestibulum eu suscipit purus, in suscipit leo. Nam urna mauris, efficitur vitae commodo non, mollis facilisis massa.</p>
</div>
<div class="page-wrapper">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam nisi sem, congue eu diam sit amet, malesuada commodo elit. Ut semper ante id lacus faucibus luctus. Mauris vitae turpis et quam blandit eleifend. Nam laoreet lacus vel egestas molestie. Pellentesque vulputate lacus id orci rutrum dapibus. Proin maximus ligula sit amet justo fringilla volutpat. Integer porta posuere tempus. Aliquam semper blandit est in faucibus.</p>
<p>Morbi vel metus lorem. Aliquam sapien massa, tempus in vehicula eu, sodales vitae magna. Sed vel rhoncus purus, tristique egestas nisi. Sed cursus nulla elit, nec malesuada augue facilisis sit amet. Morbi placerat euismod magna sit amet euismod. Duis quis feugiat massa, quis scelerisque mi. Curabitur eu quam pretium, auctor metus posuere, bibendum libero. Donec eu diam lectus. Sed pellentesque porttitor leo. Curabitur iaculis neque vel dignissim finibus. Vestibulum placerat sollicitudin dictum. Donec dignissim pharetra leo et finibus. Curabitur venenatis ligula a elit laoreet, id facilisis augue ultricies.</p>
</div>
</div>
<div class="page-footer">
page footer
</div>
</section>
</body>
I was able to more or less get what I was looking for. I set a conditional for the content in the large view to only show when the scroll was > 0. That way the smaller view isn't stretched when the other view isn't visible

Load different images from JSON file on mobile and desktop React

For better web app performance, I am showing different images on mobile and desktop due to resolution. The data is getting loaded from JSON file
[{
"_id": 9,
"title":"Text 9",
"subheader":"Dummy header 9",
"images": "images/four-1.png",
"imagesmob" : "images/four-1.webp",
"content":"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent nec velit consectetur, pretium risus vel, eleifend tortor. Integer enim nulla, iaculis sit amet leo vel, sagittis maximus leo. Aliquam semper sapien bibendum nulla consectetur, ut eleifend arcu accumsan. Duis consequat diam sed dolor convallis semper. Ut justo mauris, accumsan non tempus ut, ultrices at tellus. Quisque a sapien urna. Maecenas tempor consequat sollicitudin. Nullam volutpat a eros sit amet vestibulum. Cras sollicitudin vitae urna nec varius. Etiam nec facilisis urna.</p> <p>Donec ut dui condimentum, tincidunt tellus vitae, interdum lorem. Phasellus eget pretium enim. Morbi accumsan turpis vitae turpis venenatis ullamcorper. Proin pretium nisi nec nulla faucibus, a hendrerit turpis malesuada. Nullam id faucibus metus, id faucibus metus. Donec et massa suscipit, congue tortor non, ultricies turpis. Aliquam venenatis massa velit, id ornare ante efficitur vitae. Vivamus id dui tortor. Pellentesque sem mi, bibendum a orci hendrerit, mollis eleifend eros. Nunc sodales orci purus. Vivamus molestie porta egestas. <p>Suspendisse convallis mi ullamcorper, dapibus nisi a, semper felis. Praesent ut lacus eu neque vestibulum efficitur.<\/p> Sed dolor magna, mattis a ultricies vel, <b>tincidunt<\/b> eget enim.<\/p>"
}
]
The code file is :
<Card variant="outlined" sx={{ maxWidth:345, borderRadius: '11px' }} elevation={3}>
<CardMedia
component="img"
height="194"
image={welcom.images}
alt="Home Page"
sx={{display:{xs:'none', sm:'none',md:'block'}}}
/>
<CardMedia
component="img"
height="194"
image={welcom.imagesmob}
alt="Home Page"
sx={{display:{xs:'block', sm:'block',md:'none'}}}
/>
<CardHeader
titleTypographyProps={{fontSize: 18, fontWeight: 'bold', color: 'purple' }}
title = {welcom.title}
subheader = {welcom.subheader}
/>
<CardContent>
<div>{welcom.content}</div>
</CardContent>
</Card>
In tthis I want to load images for mobile in CardMedia, when I used display none and made other cardmedia for mobile, the image used for desktop is also getting loaded. I dont want the image for desktop to be loaded when on mobile. As this affect the website performance.
Any help will be appreciated. Thanks

Interactive table of contents in Material UI

I wish I was able to recreate this small menu from the material ui website in my app :
By now I have a component with a list and links :
import { Link, List, ListItem } from '#material-ui/core';
const burgerRecipe = [
{
id: 0,
name: "bread",
quantity: 2
},
{
id: 1,
name: "steak",
quantity: 1
},
{
id: 2,
name: "cheddar",
quantity: 1
},
{
id: 3,
name: "pickles",
quantity: 2
}
]
/**
* MenuInteractiveColumn :
* #description
*/
const MenuInteractiveColumn = props => {
return (
<>
<List>
{burgerRecipe.map(value => {
return (
<ListItem key={value.id}>
<Link href={`/reservations#${value.name}`}
underline="none"
onClick={() => {
console.info("bip bop");
}}
>
{value.name}
</Link>
</ListItem>
)
})}
</List>
<List>
{burgerRecipe.map(value => {
return (
<div id={value.name}>
{value.name} -------------
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam in lectus sit amet est mollis pharetra nec non augue. Phasellus eleifend ac erat non aliquam. Donec varius vel orci vel tempus. Suspendisse non dolor est. Duis at consequat diam. Etiam at bibendum orci, at tincidunt nulla. Integer vel quam non urna malesuada auctor. Quisque feugiat ligula dolor, vitae consequat magna mattis nec. Nulla massa nisl, fringilla et felis nec, lobortis placerat lectus. Praesent eget vehicula nulla. Cras lobortis metus sed pellentesque maximus. Proin nisi diam, euismod sit amet lacinia in, fringilla eget dolor. Nunc molestie magna id varius facilisis. Pellentesque sit amet posuere justo. Nullam faucibus lectus at mauris efficitur, sit amet hendrerit massa auctor.
Fusce a dapibus nibh, at dignissim nulla. Donec tempus ut justo eu volutpat. Pellentesque eget diam ipsum. Nullam vehicula lorem et rhoncus mattis. Duis arcu libero, consectetur a sodales eget, malesuada at purus. Integer a mattis eros. Etiam sagittis, lectus cursus commodo molestie, ante justo maximus diam, pellentesque hendrerit nibh est sed ex. Cras pharetra interdum sagittis. Nulla tincidunt scelerisque purus, eget varius ipsum venenatis porta. Etiam fermentum, diam vitae tempor tempus, quam diam iaculis eros, id fringilla sapien felis ut metus. Quisque et mi condimentum, semper justo ultrices, euismod metus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Cras posuere et nisl ac ultrices. Donec eu dolor tincidunt, maximus augue quis, suscipit metus. Praesent convallis ut metus vel eleifend.
Sed eu dignissim urna. Quisque sit amet risus sollicitudin, lobortis purus nec, consequat justo. Vestibulum non mauris faucibus, maximus nulla eu, convallis augue. Aenean vel libero nec felis ullamcorper auctor. Mauris efficitur sed tellus eget semper. Etiam blandit et lectus ut lacinia. Suspendisse faucibus enim convallis, placerat eros vitae, ullamcorper mauris. Quisque quis quam vestibulum, mollis justo ac, pellentesque nisl. Nunc iaculis tortor sit amet ex tristique convallis sit amet sit amet augue. Nulla aliquam sit amet enim eget placerat. Ut quis ex tincidunt, dignissim ligula non, euismod mauris. Sed euismod faucibus massa, vel aliquam elit euismod in.
Aliquam id sapien nibh. Sed eu tellus eros. Cras interdum magna quis arcu dignissim, eget posuere felis dictum. Donec dictum euismod lectus, nec ornare erat suscipit at. Fusce mi nibh, ullamcorper porttitor orci sit amet, placerat ultrices eros. Nam rutrum mauris sit amet magna iaculis aliquet. Sed venenatis urna in metus volutpat, id sagittis nulla tempor. Curabitur odio metus, porttitor sit amet urna ac, posuere rhoncus neque. Morbi tortor libero, dapibus vitae finibus rutrum, placerat quis leo. Vivamus nunc leo, vehicula vulputate cursus ac, placerat vitae ex. Nullam eu nisl purus. Curabitur vitae egestas turpis, quis volutpat felis. Quisque sit amet purus facilisis, posuere ante in, laoreet nisl. Pellentesque ornare dolor nec lectus porttitor, et venenatis orci auctor. Vestibulum ultrices id enim vel interdum. Ut non tortor placerat, consectetur sem at, viverra elit.
Etiam non tellus in nisl facilisis pharetra. Vivamus porttitor justo at fringilla euismod. Nunc neque lacus, scelerisque sed pellentesque quis, ullamcorper nec leo. Nullam sed dolor metus. Vivamus aliquet at erat eu blandit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque mollis neque at eros feugiat, nec lacinia lorem finibus. In semper vel lacus eu porttitor. Curabitur mollis lectus ac purus pretium, non facilisis odio viverra. Aliquam erat volutpat. Pellentesque ultrices nulla et nisi placerat, non tempus nisl elementum. Sed dui dui, vestibulum posuere enim vitae, sollicitudin rhoncus metus.
</div>
)
})}
</List>
</>
)
};
export default MenuInteractiveColumn;
And I would like it to go to some div in my page like it does on the material ui website
EDIT : It kinda works now but it hides the top of the lorem Ipsum under my navbar
While i do not have the time to make an example based on your code here are some resources which might be interesting to you:
material-ui - AppTableOfContents
react-scrollspy - see example on how this can be used with tabs
react-scroll-agent
Antd anchor
see also material-ui: issue 16359 for more information

Read more option in angularjs

I'm using this directive to implement a read-more in my ionic app.
My HTML looks like this:
<ion-list>
<ion-item class="item item-thumbnail-left item-text-wrap" ng-repeat="sh in schedule_hosts" type="item-text-wrap">
<img ng-src={{sh.imageURL}}>
<h2>{{sh.firstName}} {{sh.lastName}}</h2>
<p>{{sh.profession.EN}}</p>
<p read-more ng-model="content" words="true" length="5"></p>
</ion-item>
</ion-list>
And in my controller:
$scope.content = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi. Nulla libero. Vivamus pharetra posuere sapien. Nam consectetuer. Sed aliquam, nunc eget euismod ullamcorper, lectus nunc ullamcorper orci, fermentum bibendum enim nibh eget ipsum. Donec porttitor ligula eu dolor. Maecenas vitae nulla consequat libero cursus venenatis. Nam magna enim, accumsan eu, blandit sed, blandit a, eros." +
"Quisque facilisis erat a dui. Nam malesuada ornare dolor. Cras gravida, diam sit amet rhoncus ornare, erat elit consectetuer erat, id egestas pede nibh eget odio. Proin tincidunt, velit vel porta elementum, magna diam molestie sapien, non aliquet massa pede eu diam. Aliquam iaculis. Fusce et ipsum et nulla tristique facilisis. Donec eget sem sit amet ligula viverra gravida. Etiam vehicula urna vel turpis. Suspendisse sagittis ante a urna. Morbi a est quis orci consequat rutrum. Nullam egestas feugiat felis. Integer adipiscing semper ligula. Nunc molestie, nisl sit amet cursus convallis, sapien lectus pretium metus, vitae pretium enim wisi id lectus." +
"Proin at eros non eros adipiscing mollis. Donec semper turpis sed diam. Sed consequat ligula nec tortor. Integer eget sem. Ut vitae enim eu est vehicula gravida. Morbi ipsum ipsum, porta nec, tempor id, auctor vitae, purus. Pellentesque neque. Nulla luctus erat vitae libero. Integer nec enim. Phasellus aliquam enim et tortor. Quisque aliquet, quam elementum condimentum feugiat, tellus odio consectetuer wisi, vel nonummy sem neque in elit. Curabitur eleifend wisi iaculis ipsum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In non velit non ligula laoreet ultrices. Praesent ultricies facilisis nisl. Vivamus luctus elit sit amet mi.";
This works fine, but as you can see, the content is now the same for every item.
I looking for a way to create a read more functionality that allows me to add the text in HTML, like this:
<p read-more ng-model="content" words="true" length="5">{{sh.content}}</p>
I'm very (very) new to Angularjs and Ionic, any help is appreciated!
It seems you looking for directives. The directive is a feature same as web components.
You issue may be solved like that.
read-more-content.html
<p ng-if="content" read-more ng-model="content" words="true" length="length">{{content}}</p>
read.more.content.js
angular.module('App')
.directive('readMoreContent', function () {
return {
restrict: 'E',
transclude: true,
scope: {
content: '=',
length: '='
},
templateUrl: 'app/components/_read-more.html'
};
});
And usage can be similar like that
<read-more-content content="content" length="5"></read-more-content>
My personal advice split your own code in angular on small components/directives. That allow you avoid lot's of headacke in nearest refactoring. I'm looking forward doing something similar to http://bradfrost.com/blog/post/atomic-web-design/ but in angular.

How to get an ordered list full with in Android browser

This is probably really simple but I've been on it for ages and can't figure it out....
If I have a simple ordered list, which when I view it in Fire Fox, everything looks fine; the list is displayed the full width of the browser.
If I look at the same page in my Android browser, the list only takes up about a third the width of the screen.
I don't understand it, I have no CSS rules applied so why should the Android browser not use the full width of the screen?
Here's my HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<h2 style="text-align:center">This is a long heading which stretches across the page</h2>
<ol>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque dolor diam, lobortis eu volutpat in, accumsan vel massa. Curabitur justo mauris, tempus ut feugiat nec, pellentesque et felis. Proin aliquam varius mi a ultrices. Nam purus tellus, posuere hendrerit tristique at, blandit eu tellus. Curabitur egestas diam at nunc volutpat rhoncus. Cras elementum, magna id tristique porta, justo leo ultrices nisl, et rhoncus magna odio id purus. Aenean pretium augue ut metus congue sed lobortis urna varius. Duis augue diam, posuere sit amet viverra vel, facilisis ac odio. Vestibulum nisi orci, luctus vitae luctus eget, lacinia ut dui. Ut imperdiet, enim nec mattis laoreet, tellus elit bibendum elit, non imperdiet enim mauris eu risus. Curabitur faucibus urna sed turpis tincidunt pulvinar. Etiam tristique nisl eu nibh sodales at convallis mi mattis. Fusce imperdiet posuere lorem quis vulputate. Ut in leo in lorem fermentum hendrerit quis vitae velit. Phasellus tristique mi ac neque tempus sollicitudin. In nec interdum enim. Fusce id magna et ipsum lobortis cursus. Nunc eleifend volutpat elit, a adipiscing tellus posuere et. Phasellus id mauris ante, vehicula suscipit leo.</li><li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque dolor diam, lobortis eu volutpat in, accumsan vel massa. Curabitur justo mauris, tempus ut feugiat nec, pellentesque et felis. Proin aliquam varius mi a ultrices. Nam purus tellus, posuere hendrerit tristique at, blandit eu tellus. Curabitur egestas diam at nunc volutpat rhoncus. Cras elementum, magna id tristique porta, justo leo ultrices nisl, et rhoncus magna odio id purus. Aenean pretium augue ut metus congue sed lobortis urna varius. Duis augue diam, posuere sit amet viverra vel, facilisis ac odio. Vestibulum nisi orci, luctus vitae luctus eget, lacinia ut dui. Ut imperdiet, enim nec mattis laoreet, tellus elit bibendum elit, non imperdiet enim mauris eu risus. Curabitur faucibus urna sed turpis tincidunt pulvinar. Etiam tristique nisl eu nibh sodales at convallis mi mattis. Fusce imperdiet posuere lorem quis vulputate. Ut in leo in lorem fermentum hendrerit quis vitae velit. Phasellus tristique mi ac neque tempus sollicitudin. In nec interdum enim. Fusce id magna et ipsum lobortis cursus. Nunc eleifend volutpat elit, a adipiscing tellus posuere et. Phasellus id mauris ante, vehicula suscipit leo.</li><li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque dolor diam, lobortis eu volutpat in, accumsan vel massa. Curabitur justo mauris, tempus ut feugiat nec, pellentesque et felis. Proin aliquam varius mi a ultrices. Nam purus tellus, posuere hendrerit tristique at, blandit eu tellus. Curabitur egestas diam at nunc volutpat rhoncus. Cras elementum, magna id tristique porta, justo leo ultrices nisl, et rhoncus magna odio id purus. Aenean pretium augue ut metus congue sed lobortis urna varius. Duis augue diam, posuere sit amet viverra vel, facilisis ac odio. Vestibulum nisi orci, luctus vitae luctus eget, lacinia ut dui. Ut imperdiet, enim nec mattis laoreet, tellus elit bibendum elit, non imperdiet enim mauris eu risus. Curabitur faucibus urna sed turpis tincidunt pulvinar. Etiam tristique nisl eu nibh sodales at convallis mi mattis. Fusce imperdiet posuere lorem quis vulputate. Ut in leo in lorem fermentum hendrerit quis vitae velit. Phasellus tristique mi ac neque tempus sollicitudin. In nec interdum enim. Fusce id magna et ipsum lobortis cursus. Nunc eleifend volutpat elit, a adipiscing tellus posuere et. Phasellus id mauris ante, vehicula suscipit leo.</li><li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque dolor diam, lobortis eu volutpat in, accumsan vel massa. Curabitur justo mauris, tempus ut feugiat nec, pellentesque et felis. Proin aliquam varius mi a ultrices. Nam purus tellus, posuere hendrerit tristique at, blandit eu tellus. Curabitur egestas diam at nunc volutpat rhoncus. Cras elementum, magna id tristique porta, justo leo ultrices nisl, et rhoncus magna odio id purus. Aenean pretium augue ut metus congue sed lobortis urna varius. Duis augue diam, posuere sit amet viverra vel, facilisis ac odio. Vestibulum nisi orci, luctus vitae luctus eget, lacinia ut dui. Ut imperdiet, enim nec mattis laoreet, tellus elit bibendum elit, non imperdiet enim mauris eu risus. Curabitur faucibus urna sed turpis tincidunt pulvinar. Etiam tristique nisl eu nibh sodales at convallis mi mattis. Fusce imperdiet posuere lorem quis vulputate. Ut in leo in lorem fermentum hendrerit quis vitae velit. Phasellus tristique mi ac neque tempus sollicitudin. In nec interdum enim. Fusce id magna et ipsum lobortis cursus. Nunc eleifend volutpat elit, a adipiscing tellus posuere et. Phasellus id mauris ante, vehicula suscipit leo.</li>
</ol>
</body>
</html>
Does anyone know how to fix this?
Screenshot follows
Please add the following meta tag between your head tags:
<meta name="viewport" content="width=device-width, initial-scale=1" />
It allows you to control the viewport's size and scale. If you need more info visit this documentation.
In case anybody has this same problem, I've found the answer - it is a bug with Android autofit in ICS & JB. Gingerbread seems ok.
The answer is here - android autofit mode causing issues with css width in web page
Just apply this workaround to the in question
/* work around mobile device auto-fitting */
#media only screen and (max-device-width: 800px) {
#content p {
background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==);
background-repeat:repeat;
}
}

Resources