Viewers: in countries Watching now:
This course surveys the core principles and techniques essential to building web sites for mobile devices. Author Joe Marini introduces the mobile context, sheds light on its unique coding requirements, and discusses interface design techniques that enhance existing sites for mobile viewing. The course shows how to approach designing for mobile form factors such as smaller screens and finger-based interaction, along with how to incorporate CSS3 and HTML5 capabilities, such as geolocation, local storage, and media queries.
In addition to creating full-screen apps, some browsers provide finer control over some of their user interface behavior. For example, you can turn on and off the detection of data in a page, like phone numbers. You can customize how links are highlighted when the user taps on them. You can change the browser's behavior when links are tapped and held. And you can even control how the user is allowed to select page content. So the way that you do this is by specifying certain tags and settings inside the page's head section.
So for example, to turn off data detection, you simply specify a meta tag named format-detection and the content="telephone=no". This will prevent the browser, in this case the iPhone, from detecting phone numbers in your web pages and automatically putting links on them so that when the user taps on them, they can be dialed. If you don't want that behavior in your web app, you can turn it off. You can also control the color of link highlighting, simply by specifying a CSS style.
So for example, by specifying -webkit- tap-highlight-color, you can specify the color of links when they are tapped on. Again, if you're building a web app, especially a full-screen web app, this gives you the ability to make it look even more like a native, built-in application. You can also turn off the touch callout panel, and this is something that you usually want to do when you have a full-screen web application. So if you've ever been in the iPhone web browser and you touch on a link and you hold it, a little panel pops up from the bottom that gives you the opportunity to perform some additional actions on that link. And especially in the case of a full-screen web app, you want to turn that behavior off.
The way to do that is, once again, with a CSS style. You simply specify -webkit-touch-callout to be none, and that will turn that behavior off. If you want to turn it back on again, you just set it to inherit. You can control how the user can select text and other content in the page. So by setting the -webkit-user-select to none, the user can't select anything. You can also set it to text or auto for full selection. So in the example you see here, I've set the selection ability for all elements in the page to none except for elements that have the help class on them, because I might want the user to be able to select the text in something that I've labeled as help so they can copy it and paste it somewhere else, maybe in an email or a text message.
So let's see how all of this works in real code. So I am going to switch over to the code here. So here I am in Xcode, and this is our sample file. It's customui_start. And what we are going to do is test out some of these properties to customize how the browser responds to certain UI events. So down here you can see I've got some links, and they've got IDs on them. So this one is Tap and Hold, and this one says Tap on Me, and I've got some other stuff I am going to put in the page. So let's go up here, and I am going to go to my Snippets, and in my Snippets file, scroll down to the Customizing the User Interface section.
So I am just going to copy this, and I'll put this in the file, right up here in the head. So let's take a look at what is it that I've copied. So for elements with the ID of customHold, I've got the webkit-touch-callout set to none. For the customTap, I've got the tap highlight color set to red. And for the h1s in the page, I'm saying that the user cannot select the text in those. So let's scroll down. So here's the h1 right here. The user will not be able to select this text because of the select: none there. And then for customHold and customTap, which are right here, we should also see some special behavior.
So I am going to save this, and let's go to the Simulator. So before I actually load this up in the Simulator, let me show you the file as it currently is, and you can see that in the Tap on Me, I am getting this gray highlight color. And if I tap and hold on this link, you'll see that that little panel comes up, and I don't want that to happen. So when I refresh this in the browser, these links should have different behavior. You can also see that here I can copy text in the h1. I won't be able to do this when I have my new page loaded.
So let's go to the Finder, and I am going to copy my customui. I am going to paste it in over here. Now, I'll go back, and we'll refresh this page. Now you'll see a couple of things. First, when I tap on this link, see how the highlight color is red, whereas this one is gray. So I've customized the color there. You can also see that when I tap and hold on this link, I get the panel, but when I tap and hold on this link, I don't. So that behavior has now been turned off. And you notice that I can't select text in the h1 anymore.
Notice how the selection starts out down here in the paragraph, but I can't actually select the text up here. So just by specifying some attributes, some style sheets, and some other meta tags, I am able to have finer control over how the iPhone manipulates and responds to events in my web page, and when I am building things like full-screen web apps, this really comes in handy.
There are currently no FAQs about Mobile Web Design & Development Fundamentals.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.