02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Mobile responsiveness

Just by moving planning and designing your site to be responsive it will look better and will be more useful for users. The next step is to customize and improve the flow and layout for mobile output. By the end of this lesson you will learn about how to optimize mobile responsive design and how to update the orientation of the design based on device orientation.

Keynotes:

  • Thinking mobile when designing responsive designs
  • Mobile view ports
  • Reacting to Mobile Orientation.

properties:

media queries, HTML4, CSS2.1, responsive design, mobile design, orientation

Video Transcript

00:00In the last lecture we created a mobile, well not mobile, we created a responsive
00:04design but if you tried to put on your mobile device you would see that it was
00:08not really responsive there and your design probably didn't look the way
00:12you wanted it to look like. And that's really the topic of this lecture where
00:16we're gonna start thinking about mobile design in general and see how to
00:20create your responsive design to work better in mobile devices as well. We're
00:25gonna use that, do that through something that's called viewport which
00:29is not yet a specification but is in the process to becoming one. And we're gonna
00:33look also at how to create different layouts depending on your mobile
00:38orientation. So let's get right into it. I'm gonna go into my right into my
00:43editor and I'm gonna start off with the viewport and I'm gonna show you the core
00:49viewpoint characteristic. Literally what you want to do is go into your head
00:53area and in your head you want to add more another meta description and I'm
00:58going to go ahead here and add here a meta and the name of this meta
01:01description is viewport. Now it has content and the content itself is
01:07basically the rules that we want to send into it and really the rule in our
01:11case is I want to set a width and I want to define a width. Now why do I want
01:16to do that is very simple. When I don't do that the mobile device by
01:21general is gonna hard code a value because if your design was for 1,200
01:26or your design was for a width that is much larger than the size of the device
01:29what the device is basically gonna do is send to that website define what
01:36that height of that website is by default and then squeeze the content into the
01:40area of the screen. What we want to say to it no no no don't do that instead of
01:45that go to your device itself device and set your device width to be the
01:51width. In other words we're saying don't resize the the screen set the screen set
01:58the website to be in the size of the screen is itself without resampling. In
02:03other words I'm literally telling to the viewpoint that the width of my website
02:07is the width of the device that we're in. Now this is only valid for mobile
02:11devices and what that does it cancels off that automatic resizing or zooming
02:17in or scaling of our website giving the control back to us as the developers. Now
02:23once I do that and we're not going to see a difference on our desktop but once
02:27I do that if I just open up here a sample of how the site would look like
02:31before so if you didn't check it out on a mobile device before we set the
02:36actual view with a width to be the device width this is how it looked like.
02:41Once we've set it once we've configured it it's actually gonna do what we
02:45wanted it to do and there you go that's what we really wanted to do. Now before
02:50we wrap up this topic and move on to the topic of orientation I just want to
02:54give you like a small reminder or a mention that if you go into target
02:59device targeting into the blog post you'll see in the blog post also
03:04mobile devices and view and the viewport which you'll see that viewport
03:08we just created and you could click onto the CSS specifications to read more
03:13about different things you could do with the viewport and you'll see that it has
03:17a few properties of the width height initial scale minimum scale maximum scale
03:21user scale scalable do we want to not let the user to scale the content do we
03:27want to set a default scale really if we want to set an initial scale it makes
03:31a good a good amount of sense to do that then we would go into our device
03:35making sure even if the user changed the scale that our scale our initial
03:40scale will always be one making sure that we'll have that original normal
03:44scaling even if the user zoomed in so when the user comes here initially
03:48they'll have that initial scale but we're not forcing the user to stay
03:51there because they could always resize with their device itself so that's it
03:56about the viewport and I want to move back into our styling and in our
04:00styling I'm going to go right into our media styles and I want to talk
04:04about orientation really quickly so the media tab basically enables me also
04:09to define a rule for orientation and let me just make sure that I type this
04:14correctly for my orientation of portrait which is really the default in mobile
04:19devices and landscape which is really ranscape which is really the default in
04:25a desktop so I'm gonna go ahead and just paste here just a background color
04:30change to black that I've set inside of our orientation landscape as you saw
04:35in our sample already I already refreshed earlier and you can see that
04:39we have here a black background and this black background is really because by
04:42default on a desktop our orientation is landscape contrary to that the default
04:47orientation on the mobile device in general unless you're orienting the
04:52device sideways is gonna be portrait so let's go ahead so let's go ahead and
05:01basically create another media rule and I'm just gonna paste here this media
05:05rule and change it to portrait poor great and I'm gonna set my background
05:14color to be red now I'm not gonna see any difference inside of my browser right
05:18now because still I am on a desktop so I'm gonna go ahead and show you how it
05:22would look like on a mobile device and let me just bear with me for a second
05:26to find that sample and here we go so let me just focus on that sample get
05:30rid of that sample get it out of the way we'll see that you'll see that the
05:34default perspective which was portrait we'll see that our background is red as
05:38you can see on the top here and once we flip it to be if to we flip to the
05:44landscape we see that it's black in our mobile device as well so really that
05:48that's all we really wanted to talk about for specific alities when it
05:52comes to mobile devices there is over we talked about the handheld property
05:57that enables us to target handheld devices but in generally generally
06:02generally I encourage you not to use it and that is because it seems that in the
06:06future in CSS future that is not going to be the preferred way of doing it
06:11anymore so as long as we could do it with features asking specifically for
06:15specific features try to focus on that instead of using the media type of
06:22handheld even though it will be supported best not to use something that
06:26we know is planned to be phased out in the future so that's it we're done
06:31talking about mobile but we're definitely not done with this chapter because we
06:35have one more topic to talk about which is backwards compatibility or backward
06:40compatibility I wrote but backwards compatibility which basically means how
06:44do we make sure that our designs will look good and work on devices that are
06:48just older so we're going to talk about that as the wrapping up of this
06:52section

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!