I have at least one very huge “old school” design website which I’d like to make a little more mobile friendly. By a “little” more, I mean I’m trying to avoid rebuilding everything and having completely separate mobile and desktop sites. Thats probably not even do-able, but I’d like to try. In several experiments I’ve already seen that if I simply change the body font-size % style, a lot of pages could be made fairly universal with just a few tweaks. But two rubs… first, I can’t detect page size until the page has been loaded. I think I can solve that with one dummy “landing” page, which could then make some tweaks in subsequent pages being loaded. But then the bigger question, just what is page size anyway?
What I’m getting at is, pixel size (which I can get through DOM properties) doesn’t mean anything anymore. Mobil devices have gotten so hi-res, the pixel density is comparable to a desktop monitor. What I really need to know, besides pixel size, is how big the screen actually is. If I know its 800 pixels wide, that means nothing. If I know that 800 pixels equals 2.5 inches, NOW I can make some useful calculations. But is there a reliable way (other then a lookup table for every device) to know how big the screen really is? Inches, centimeters, doesn’t matter… as long as its a real measurment, I can use it.
Hi,
How are you going to know from the physical size of the screen what angular dimension that is at any given time?
I therefore suggest that you simply use responsive design techniques based on a "standard" pixel density viewed from a "standard" distance, and let the smartphone manufacturers worry about how they represent that on their devices! ?[/QUOTE]
Well, I do not have an answer, except that designing for each and every mobile device out there has been tried. I think it was called "adaptive design" (or some such). Fact is, it did not work, and never could. E.g. How do you allow for devices that have not been made yet??? The life of the average mobile seems fleetingly short, and you are just making a rod for your own back trying to do the impossible.
On second thoughts, have you tried sizing things in EMs instead of PXs? I dislike the EM but it should re-size better...
Oh, and part of the problem is your use of a fixed width element 640px wide in the first place. How is that ever going to work on a 320x480px screen? It isn't. So don't do it! ?[/QUOTE]
[CODE]body {
font-size: 3vw;
font-family : "Comic Sans MS", "ChalkboardSE-Bold", "Times New Roman", Times, serif;
font-weight : bold;
text-align: center;
background-color: #33cc99;
} [/CODE]
Glad to be of assistance, just a few comments:
1. Do you realise that vw units are CSS3 specific and have no fall-back for legacy browsers (including IE8 and below)? Backward compatibility is less important now than it used to be, and minor display discrepancies are acceptable, but I suspect this could lead to major display errors on such browsers.
[/QUOTE]
[CODE] <style>
body {
font-size: 20pt;
font-size: 3vw;
font-family : "Comic Sans MS", "ChalkboardSE-Bold", "Times New Roman", Times, serif;
}
</style>
[/CODE]
2. I'm not sure what you mean by [I]"I'll definitely need to give up on the idea of one size fits all web pages"[/I]. I suspect that you are confusing fluid design techniques with responsive ones. Yes, fluid design techniques (even with vw units) cannot make a complex web page fit screens from 320px wide to full HD (and larger). That is what media queries are all about. They enable you to:
[/QUOTE]
a) Reformat the layout in ways that simple fluid design cannot do.
b) Add, amend and delete content to suit the media.
So full page content (displayable on a large screen) can be reduced to an epitome on small screen devices, without having to develop the web pages separately.
[/QUOTE]
[CODE]@media screen and (max-width: 640px) { ... }[/CODE]
[CODE] @media screen and (max-width: 320px) { ... }
[/CODE]
Thanks for the continued advise! Let me comment on these items one by one, and I'll understand if I'm starting t be a pest here...[/quote]
I'm hoping it is safe to assume that mobile devices are likely to be a bit more current, at least when it comes to newer CSS options.
[/quote]
Tell me... is it OK to have two identical properties in the came style, so that the second will only activate if the first fails, like this...
[CODE] <style>
body {
font-size: 20pt;
font-size: 3vw;
font-family : "Comic Sans MS", "ChalkboardSE-Bold", "Times New Roman", Times, serif;
}
</style>
[/CODE]
Obviously font family is already capable of falling back. But what about coaxing the font-size like that?
[/quote]
[code=html]
<head>
<style>
.easy p {
font-size: 14pt;
}
p {
font-size: 12pt;
}
</style>
</head>
<body>
<p>This is font-size 12pt</p>
<p class="easy">This is font-size 14pt</p>
</body>
[/code]
Well first, go back to my original dilemma, which is that 640 pixels on a Mobil device is way different from 640 pixels on an old fashioned VGA screen. If all I have is constructs like...
[CODE]@media screen and (max-width: 640px) { ... }[/CODE]
That isn't going to help me properly size text at all. I became hopeful because it seems there is a 'resolution' property that can somehow determine the DPI of a screen, so maybe with that I can make some calculations about text sizes that really reflect the actual visual experience, rather than deciding styles based on pixels (which don't really mean anything).
[/quote]
Second, I have to confess that I honestly just don't "get" how media rules work...
(a) if three media rules all turn out "true", which one overrides the rest? is it a case of the last rule overrides the previous, a case of the first rule causing the remaining ones to be ignored (like HTML5 video media formats), or is it (gasp!) browser dependent.
[/quote]
I also seem to be having a hard time understanding in a rule like this...
[CODE] @media screen and (max-width: 320px) { ... }
[/CODE]
Does this infer that ALL widths 320 and less satisfy the rule? Confusing!
[/QUOTE]
Pixel dimensions tell you what percentage of the available screen height will be taken usually doesn't know the actual dimensions of the screen, just the number of pixels.Zoom Google map to fit the world, on any screen.Screen size detect physical dimensions of your display in inches. Screen size is computed based on CSS 1" size in pixels and might be inaccurate.Different devices can have a similar screen resolution, yet entirely different physical ....
[/QUOTE]
1. Settings are applied top down, with the later ones overriding earlier ones. So in your example, if both font-size settings are understood by the browser, font-size will be set to 3vw.
[/QUOTE]
My answer to this remains the same. The actual physical size of the text display is not your concern, for the very good reasons:
1. It is the angular dimension that is key, not the physical size of the text. E.g. Text 2 centimeter high on a screen held 20cm from the eye is the same "size" (to you) as text 4 centimeter high on a screen held 40cm from the eye, which is the same "size" as text 30 centimeter high on a screen 3m from the eye.
2. The size of text that a reader may find comfortable varies (often with age and infirmity).
Since you have no way of knowing how far away the screen is fron any given user's eyes, nor their age or infirmity, any attempt at second-guessing this is futile. Also:
3. Facilities exist in mobiles and PCs to allow the user to scale the text to suit their needs anyway!
4. Knowing the device or window width is useful in that it allows the content to fit the available width, thus minimising (or eliminating) the need for horizontal scrolling whilst reading text etc. I.e. You are trying to use it for the wrong reasons.
[/QUOTE]
[CODE]
body {
font-size: 3vw;
font-family : "Comic Sans MS", "ChalkboardSE-Bold", "Times New Roman", Times, serif;
font-weight : bold;
text-align: center;
background-color: #33cc99;
}
@media screen and (max-width: 320px) {
body {
font-size: 200%;
background-color: lightblue; // so I'll know for sure
}
[/CODE]
[CODE]
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=1"/>
[/CODE]
<i>
</i>@media screen and (max-width: 320px) {
body {
font-size: 200%;
background-color: lightblue; // so I'll know for sure
} <br/>
}
<i>
</i>@media screen and (max-[b]device[/b]-width: 320px) {
body {
font-size: 200%;
background-color: lightblue; [b]/*[/b] so I'll know for sure [b]*/[/b]
} <br/>
}
<i>
</i><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=1"/>
<i>
</i><meta name="viewport" content="width=device-width, initial-scale=1">
How many other smart phones or mobile devices require secret additions like this to make media rules work?
[/quote]
This is one of the reasons I'd really like to see a GOOD and COMPLETE tutorial on the subject.
[/quote]
...without the VIEWPORT meta tag, do the @media rules specifying "width" have any predictable meaning at all?
[/quote]
And by the way, not that I'm in a position to judge yet, but everything I've read dso far seems to say I should avoid "max-[B]device[/B]-width" in favor of using the browser window, which I guess is just "max-width". When would YOU say one is better than the other?
[/quote]
<i>
</i>/* default */
html {
width: 100%;
} <br/>
body {
width: 960px;
margin: 0 auto;
}
/* media queries */
@media screen and (max-width: 960px) {
body {
width: 800px;
}
}
@media screen and (max-width:800px) {
body {
width: 640px;
}
}
@media screen and (max-width: 640px) {
body {
width: 480px;
}
}
@media screen and (max-device-width: 480px) {
body {
/* smartphone */
width:100%
}
By the way... new discovery! I don't know how reliable it is, but in Firefox if you view a page after hitting CTRL-SHIFT-M, it seems to let you view the current page as a mobil device would, and it seems to let you select from quite a few devices! If the simulation is even 90% reliable, it will be a BIG help as I retrofit old pages!
[/QUOTE]
... I use roughly the following:
<i>
</i>/* default */
html {
width: 100%;
} <br/>
body {
width: 960px;
margin: 0 auto;
}
/* media queries */
@media screen and (max-width: 960px) {
body {
width: 800px;
}
}
@media screen and (max-width:800px) {
body {
width: 640px;
}
}
@media screen and (max-width: 640px) {
body {
width: 480px;
}
}
@media screen and (max-device-width: 480px) {
body {
/* smartphone */
width:100%
}
.[/QUOTE]
[CODE]<style>
p, ul, ol, li {
font-size: 1em;
font-size: .65rem;
}
</style>[/CODE]
Styling the HTML tag is not new. It has, however, been little used for whatever reason. Similarly the ability to set the width of the BODY element to less (or more) than the viewport is often overlooked.
[/QUOTE]
If you feel more comfortable with it, substitute BODY for HTML, and an ID "container" for BODY. The effect is the same, but it introduces an entirely unnecessary third element to achieve what can be done with HTML and BODY alone!
[/QUOTE]
0.1.9 — BETA 5.15