Forum Moderators: not2easy
I have a bunch of articles stored in my database for my website
In these articles are divs and tables where their width may be defined
I am trying to show these articles in an iPhone version of the site i am making, but i can't figure out, short of taking the actual text and using pattern match and replace, how to keep the content inside the "viewport" width
so for instance, here's an article text from the database
<div style="width: 600px;">
Blah blah blah, this is my article with images and text and tables and all that
</div>
and i want to keep that in a parent div (that's just '100%' the width of the viewport)
Is that possible with straight CSS?
I've already got some code on the server that takes care of images larger than the viewport size, but i can't figure out how to keep those defined div tags inside the view without resorting to taking the text and looking for those width's, as many people have authored articles so it could be spelled many ways, spacing may be different, may be defined by CSS, etc etc
Thanks in advance
- Steve
I'm fairly new to using CSS but I'm learning fast (I think).
Your main problem is no control of the articles written by other authors.
In your example you show an element with an inline style (div style="width: 600px;">) By the rules of CSS their is only one way to over ride this style rule. In the style section within the head section of your web page that you would be sending to the iphone is to add this style rule.
div{width: 100% !important;}
This should overide all style rules for div except user's style rule that is also label !improtant. Also I don't know it this will over ride div style rules that have a "class" or an "id". Another thing is that this will only work for div elements. If some other html elements are style with a fix width they might cause you problems. Also if some the of html elements have their own "width" keyword, it may cause you problems.
The best thing to do is create a style sheet that meet all the requirements of your iphone display and have your authors write to these standards.
HTH
PhotoJoe