Showing posts with label iPhone. Show all posts
Showing posts with label iPhone. Show all posts

Friday, October 31, 2014

How to Format a Website for Mobile Devices (like the iPhone) using HTML 5 and CSS


Have you ever worked really hard to created a really cool website that looks great on a browser and large tablet PC only to view it on a mobile device (like a Smartphone) and have it nearly impossible to read? Me, too. But what is one to do? Create a whole separate website just for phones and try and reroute traffic? And what happens when something new comes up like a Retina display? Create a third site?

History


Someone came up with a really cool solution that is known today as Responsive Design. You can read the original article (according to Wikipedia, but I wouldn't be surprised if someone else stumbled upon this earlier) by Cameron Adams in 2004 at http://www.themaninblue.com/writing/perspective/2004/09/21/. You'll notice he called it Resolution Dependent Layout. I used to design websites with the same mindset that they reshape themselves to whatever size starting in 2002, but we didn't have the cool CSS tools, the large bandwidth, or the wide browser support we do today. I called my approach Organic HTML, which I still think is the best name. Feel free to spread it around and see if it catches on.

Approaches


There are a lot of different approaches that one can take. There are also hundreds of different devices and screen sizes one has to consider. One school of thought is to create a separate site for each screen size. But this becomes a nightmare to update.

My approach is to basically design your site so it works well for larger screens (desktops, laptops, and large tablets) and small screens (phones and small tablets) and use Cascading Style Sheets to create a different layout for each. You may be saying to yourself, "But i want to customize my site to look just so on every device." Yeah, there are too many devices--your code will be so bulky it won't load right and your sanity will have checked out long before you get halfway thru the list.

There are two important subjects to consider. First is the code to make the site behave how you want. The other is designing the site to look good and to be easily read and navigated. Both must be skillfully executed to successfully create a site that adapts to different devices. This post will cover the code aspects. A later post will cover design considerations.

It is also important to note, that this approach works best with what is wrongly called html5 and modern browsers, i.e. Mozilla Firefox 3.5+, Google Chrome 2+, Apple Safari 3.1+, and recent versions of mobile browsers. Versions of Microsoft Internet Explorer before 9 were NOT designed to properly render html5, CSS 3, or other techniques. While these browsers make up around 10% of the market, they are still significant enough to consider. You may need to add IE specific code to correct rendering errors of an html5 approach.

Code


Below are some tricks and techniques you can use to code your site to adapt to different screen sizes.
  1. Set the iPhone Retina (or other mobile device with high density display) to view the site as a mobile device with a low resolution display and not a desktop even though you have the pixels to do so.
    1. Add the following tag inside the <head> tags: 
    2. Set the min-width of either the <body> or the <div> containing the site to around 800. This isn't essential but will help you control how your site appears on smaller screens.
  2. iPhone Home Screen Icon
    1. Create a 57 x 57 png. Do not create rounded edges or a shiny effect. The iOS device will do that for you.
    2. Call it apple-touch-icon.png
    3. Place it in the root directory of your website. This will be the default icon for your site if someone wants to save it on their home screen like it was an app.
    4. iPad Home Screen Icon
      1. Create a 75 x 75 png. 
      2. Call it touch-icon-ipad.png. Do not create rounded edges or a shiny effect. The iOS device will do that for you.
      3. Place it in the root directory of your website.
      4. Add the following tag to the <head> section of EACH webpage: <link href="touch-icon-ipad.png" rel="apple-touch-icon" sizes="76x76">
    5. iPhone Retina Display Home Screen Icon
      1. Create a 120 x 120 png. 
      2. Call it touch-icon-iphone-retina.png
      3. Place it in the root directory of your website. This will be the default icon for your site if someone wants to save it on their home screen like it was an app.
      4. Add the following tag to the <head> section of EACH webpage: <link href="touch-icon-iphone-retina.png" rel="apple-touch-icon" sizes="120x120">
    6. iPad Home Screen Icon
      1. Create a 152 x 152 png. 
      2. Call it touch-icon-ipad-retina.png
      3. Place it in the root directory of your website. This will be the default icon for your site if someone wants to save it on their home screen like it was an app.
      4. Add the following tag to the <head> section of EACH webpage: <link href="touch-icon-ipad-retina.png" rel="apple-touch-icon" sizes="152x152">
    7. Fonts
      1. In the Style Sheets, set the fonts using ems, NOT pixels or points. Ems will allow the fonts to scale as the size of the website changes. 1 em is a good default for text meant to be read.
      2. Caution: If you set multiple rules, the effect will multiply. For example, if you set the font-size of 1.2 ems for elements in a <div>, and then set 1.2 ems for an specific element inside the <div>, it will be 1.2 times larger than the 1.2 of the <div>, i.e. larger than you were expecting.
    8. Images
      1. Set the Width and Height of images to 100%. Set a max-height and max-width to the size in pixels you want the image to appear on a desktop at full screen. This will allow the images to scale smaller.
    9. Layouts
      1. While <table> provides the most robust and consistent layout framework, it won't work with Responsive Design, so you'll have to use <div> and CSS-P techniques to layout your site. But you've probably been doing this for years.
      2. Use percentages and NOT pixel sizes to set width and height. This will allow the design to adapt more freely. Pixel sizes are good for max-width and max-height (or min-width and min-height).
    10. CSS branching
      1. Write your CSS code like you would normally for a desktop browser.
      2. At the bottom add @media screen and (max-width: 980px) { } (or use a different pixel size for the max-width) and write a new set of CSS code in side the brackets for the specific elements (NOT all elements) that need to change for the smaller screen. For example, if you have three columns in your site, you may want to reduce them to one; use smaller images; enlarge text; set certain elements to disappear with the display: none; style attribute.
    11. Test your site on several devices. Depending on the design of your site and the audience, you'll want to adjust the numbers and settings until it appears just right on your site. The above is just to get you started. Modern browsers allow you to drag the corner of the browser and resize it to give you a rough idea of how it will appear on a mobile device, but it isn't perfect. You need to test the site on a real phone.

    The above list are basic techniques and approaches to turn your site into a mobile site. It's not meant to be exhaustive covering every technique, but it is sufficient to make your site mobile friendly. And there are lots of other resources on the web for other techniques. Here are a few I've found helpful:

Tuesday, April 12, 2011

A few thoughts on Digital Comics

I use to be a big time comic fan, then I stopped reading them for a while, then I started reading them again but not with the same enthusiasm.

Recently Comixology released a few numbers about the growth of digital comics. They are growing, but more slowly than other media that went digital like music, movies, and books. It’s too soon and the data too scarce to make any definitive statements about them, but here are a few of my thoughts.

Why do people buy Digital Comics when they can get them on paper?
1) Price – Comics cost $2.99-3.99 per 22-page issue. When I started buying comics in 1989, most comics cost $1.00 while Superman comics cost 75 cents. That means they’ve increased in price by a factor between 3-5. Paperback books haven’t even doubled in price during the same period. Paper comics are pricing themselves into oblivion. The current diehard fans that are willing to spend too much and buy multiple copies for variant covers are the main thing keeping the current system going; very few new fans are entering the market threatening its survival. Digital Comics are currently sold for between 99 cents and $1.99. I feel this is the main reason digital comics are growing--the print market is so far above market price that it is forcing competition to emerge, a phenomenon that has been observed in the past and been misinterpreted by courts as a lack of monopoly instead of the result of a monopoly.

2) Coolness Factor – With the launch of the iPhone, Android phones, the Kindle and other eReaders, and the iPad, downloading digital is the current “new and cool”. People download apps they’ll never use, books they’ll never read, and music they’ll never listen to a second time. Why? Because it’s cool, and this has led many people who don’t read comics to start downloading digital comics. This is one reason certain titles have seen growth in digital sales without any loss in sales for the paper version.

3) Availability – Every year more and more comics shops close their doors. Fewer and fewer newsstands carry comics. And while the Direct Market was set up to over order comics so they’d have back issues to sell, the current goal is complete sellthrough so the shop isn’t stuck with unsold issues. Digital issues in theory should always be available in whatever quantity they’re demanded. This is probably the least compelling reason.

So are digital comics the future? Maybe. I personally like paper comics better, but I won’t be able to afford to buy them for much longer at current prices. And many times I’ll wait for the trade paperback and buy it at a discount at Amazon, which doesn’t help the Direct Market system or local comic shops.

Of course, there are challenges:

1) Collectablity – A digital file is unlikely to increase in value.

2) Readability – While one can read a comic book on a giant computer screen, it’s not a pleasant experience. People like to download and consume content on their iPhones and Kindles and iPads and other gadgets, but their screens are too small to read current comics. Some have tried to cut up the comic into individual panels, but that usually results in odd configurations and cropped artwork. Others have tried to zoom from panel to panel, but then you lose the “page as a whole” design the artist intended and again miss out on some of the artwork.

3) Technology – Anyone who has tried to download and read a digital comic knows it takes a lot of time and processing power. It’s kind of a buzz kill waiting and waiting and waiting only to have the comic crash.

4) Price - Digital comics are currently sold for between 99 cents and $1.99. I’m not sure these are the right prices, being a creator and seller of digital comics myself. At 99 cents you don’t make enough profit to sustain or grow the business unless every issue is a blockbuster which it won’t be. As a consumer I’m resistant to spend $1.99 on something that isn’t physical and that is hard to read.
Is there anyway to overcome these challenges. Of course!

1) Focus on complete collections over the one “hot” issue. Make having every issue seem as great as that limited first issue going for $40 on eBay. I don’t know how well it will work though. But if people actually read the comics instead of storing them in Mylar, it may.

2) In the 80s it was common for action figures to come packaged with a mini-comic. They were usually aroung 5” x 6.5” and would be easy to read even on a smart phone screen. In Brazil they sell comics in digest sizes with three issues per book. This makes the cost per issue much lower than it is in America, and they have to translate the dialogue anyway so adjusting it for the smaller space has to be done anyway. (In case you haven’t guessed, I’m proposing creating new comics as mini-comics; that way you still get the total effect of the page while maintaining readability. Plus you have fewer panels per page, so there are more pages and it appears to be a better value. Of course, this isn’t helpful for older comics. There is no good solution for those.

3) The technology problem will solve itself as Internet speeds become faster and devices become more powerful. Of course, better coding would speed up the process.

4) $1.50 seems like a good price to me. That’s what I sell a lot of comics at, and they sell as well as the ones I price at 99 cents, but I’m actually making enough money to make it worth my while. Of course, the packaging multiple issues together would allow for lower per issue prices and may be the way to go, especially for long stories that can’t be wrapped up in 22 pages.

I don’t see digital comics ever completely replacing print comics just as digital music hasn’t replaced hard media and eBooks haven’t replaced print books. There are things print can do digital can’t, and if the industry takes advantage of that, then print can have a healthy future.

But I have my doubts they will.

Monday, March 23, 2009

The Amazon Kindle

The day Amazon announced their new Kindle, the Kindle 2, I pre-ordered mine. It is a wonderful device! It is so easy to read. It is so easy to preview and buy books via the cellular phone network. It is so easy to load your own books onto that you can download free from the Internet. And the battery life is really good. I didn't know how it could get any better.

Then, just before my Kindle arrived, Amazon released a free Kindle application for the iPhone that lets you read your books you've already purchased from the Kindle store AND sync your reading progress with your Kindle. Plus, you can view the books in color. How could it get any better?

Then I discovered how easy it was to self publish your own book. So I decided to publish my own. I created a comic book and have been trying to get it published. So I said to myself, "Self, why not publish your comic book via the Kindle Store." Well, being as disposed to taking a wise man's advice as I am, I decided to do just that. You can see the cover, and issue one is currently on sale. Anyone with a Kindle, iPhone, or iPod Touch can purchase and enjoy it. Just search for Wandering Koala on Amazon.com.