Re: determining screen resolution over the web
Knute Johnson <eternal@knutejohnson.com> writes:
In CSS:
Recently, I started to teach JavaScript. This means that I
had to learn about ?Progressive Enhancement?. This means
that I had to learn about CSS3 and HTML5. This means that I
had to learn about ?Responsive Design?. So, I learnt that
with Progressive Enhancement and Responsive Design, today,
one uses CSS like
@media screen and (max-width:750px) and (min-width:500px)
{ a { width: 50%; }}
@media screen and (min-width:750px)
{ a { width: 25%; white-space: nowrap; }}
to specify formatting for different screen sizes. If necessary,
one also can write JavaScript like
if( window.matchMedia( 'only screen and (max-device-width: 450px)' ).matches )
....
else if
( window.matchMedia( 'only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation: portrait)').matches )...
. The old style might have been to access
window.screen.width, window.screen.height,
window.screen.availWidth, window.screen.availHeight,
window.screen.colorDepth, and window.screen.pixelDepth in
JavaScript, ... no, actually, the old style is browser
sniffing and then loading pages from different servers, like
a special server for a ?mobile version? of a site.
Actually, JavaScript as a language has nothing to do with
Browsers or HMTL, but students of a JavaScript course expect
you to also talk about JavaScript in the Browser. So, I also
talk about when it's better to do something using CSS than
with JavaScript. With Progressive Enhancement, I think,
one tries to do as much Responsive Design in CSS and only
resorts to JavaScript where CSS cannot help.
So, you are right mentioning CSS.
I have devised a new rule for easy pronunciation: Use the
first and last letter with an ?i? in between: So ?CSS?
can be pronounced ?cis?, ?PDF? ?pif?, ?HTML? ?hil?, ?XHMTL?
?xil?, ?XML? ?egg smell? (this is a special-case rule in
my pronunciation system that I had not mentioned before
for the sake of simplification). ?Java? is usually not
pronounced ?jia?, because ?Java? already can be pronounced
easily as it is, so the rule does not apply.