<<

White Paper

Designing for Mobile using Responsive Amelia Marschall-Miller WHITE PAPER / Designing for Mobile Websites using Responsive Design

The Social Imperative images adapted with media queries – the ultimate goal being a single , optimized for any screen size. Over the last few years, the community (AWD) also uses media queries has seen a monumental shift in how we think about to set breakpoints and create separate fixed-width and create websites, due to the rapid rise of mobile layouts, optimized for multiple screen sizes. So while browser use. From initially just making sure a site responsive website layouts change fluidly to account “worked” on mobile, we are now expected to make for any browser width, adaptive websites may have sure sites are “optimized” for mobile: providing a slightly less than ideal layouts between breakpoints. great user experience no matter the device viewing a site. There are several ways to accomplish this, A third option to achieve a mobile-friendly website is and one of the most talked about techniques is to develop a dedicated, standalone mobile website. (RWD). Unlike RWD and AWD, a dedicated mobile website is developed independent from a corresponding Mashable dubbed 2013 “The Year of Responsive desktop site, and browser detection is used to 1 Web Design” ; now is the time to fully understand redirect mobile users to the correct site. what it takes to have a responsive website, and decide if 2013 will be the year you or your organization will RWD, AWD, and dedicated mobile websites all take this leap. have their advantages and disadvantages. The following charts compare these techniques and native mobile applications.

KNOW THIS…

Mashable dubbed 2013 KNOW THIS… “The Year of Responsive Web Design” Websites running on a Content Management System with easily customizable CSS layouts, such as Is RWD Right for Me? DNN, are ideal candidates for RWD. Before we go in depth about how to develop an RWD website, it’s important to understand the different options available to achieve a mobile-friendly These pros and cons apply differently to every website, and ensure that Responsive Web Design organization. Sometimes larger organizations prefer is the right choice for your needs. In a nutshell, a a dedicated mobile site, with mobile-specific content responsive website uses a fluid layout and flexible

1 WHITE PAPER / Designing for Mobile Websites using Responsive Design

Dedicated Mobile RWD AWD Native Mobile App Website

Content Easy Easy Moderate Difficult Maintenance Single version of con- Single version of con- Multiple content Programmers usually tent is maintained. tent is maintained. versions need to be need to make content maintained (however, changes; sometimes this could be seen as a content updates re- benefit if mobile-spe- quire resubmission for cific content is desired, app store approval. such as for marketing purposes).

Device High Moderate Moderate Difficult Optimization Optimized for any Could have less than Can be tricky to imple- Custom development device. ideal layouts and some ment and test mobile is required for each horizontal scrolling detection and redirec- platform (iOS, Android, between breakpoints. tion; unless you have a and so on); tough to CMS solution that has customize between a preview option and device screen sizes. offers tablet redirection.

Development Moderate Low Moderate High Time & Cost Slightly more time Slightly less time consum- Requires a separate Requires extensive consuming than a ing than RWD; can most website development. development specific new desktop-only easily be applied to an However, features like to each platform. website development. existing desktop website. module sharing can re- duce the effort required.

Performance Moderate Moderate High High Can be less than ideal Can be less than ideal A mobile-specific site can Native applications are since entire site con- since entire site content be developed to include usually developed to tent is usually loaded in is usually loaded in less content and resources perform quickly. most viewing cases. most viewing cases. than its desktop counterpart.

Per Device Difficult Difficult Easy Moderate Flow Having a single website Having a single website Flows can be optimized Flows can be optimized Optimization makes it difficult to makes it difficult to for different devices for different devices but modify the flow for modify the flow for using multiple site requires more exten- different devices. different devices. variations. sive development.

Adding Difficult Moderate Easy Difficult Mobile to Usually requires Can be more easily Can simply focus on Can simply focus on an existing redesign of existing applied to an existing adding the new mo- adding the new mobile website website, and a com- site that RWD, using bile-specific specific site content but plete redevelopment a set Media Query site content. requires more exten- works best. breakpoint. sive development.

2 WHITE PAPER / Designing for Mobile Websites using Responsive Design

for marketing purposes, to avoid modifying any Designing a Responsive Website current desktop website. Dedicated mobile sites are also sometimes developed using some responsive There are more elements to consider when designing techniques, so the “mobile” website version also looks a responsive website, but the process can easily good on tablets and not just certain phones. But the be adapted into your current design style. Before combination of centralized content maintenance and developing a responsive site, it is most helpful to start optimization across all devices often makes RWD the with for at least three screen sizes: desktop, best choice for many organizations, small and large. tablet, and mobile. These mockups do not need to be No matter the website technique, a website solution created at any particular device size, since the website is always going to be less costly than a native app. will be optimized in between these snapshots as well.

KNOW THIS…

Regardless of the preferred design process, it is important to understand how a responsive website layout is modified during development to provide workable mockups.

Websites running on a Content Management It may be most comfortable to design the desktop System with easily customizable CSS layouts, such layout first, which can work fine. After that, you can as DNN, are ideal candidates for RWD. In DNN, a determine how the layout should change when responsive design is applied in the skin files, just shrinking the width for tablet and mobile device like any non-responsive design. Your columns and sizes. Or, many RWD proponents advocate a “mobile content panes are laid out as usual in the skin.ascx first” process. From a design standpoint, this means file, while the responsive styles are added using thinking about your content and what is absolutely media quires in skin.. necessary for a mobile user, designing the mobile layout first and adding more content as is appropriate

If you want to “mobilize” an existing site, creating when designing the tablet and desktop layouts. a separate dedicated mobile site or using AWD will likely be easier to implement than full RWD. Regardless of the preferred design process, it is Responsive Web Design works best when you can important to understand how a responsive website start with a new code layout and well thought out layout is modified during development to provide design, which we discuss in the next section. workable mockups. Responsive websites use columns

3 WHITE PAPER / Designing for Mobile Websites using Responsive Design

of content “floated” next to each other. As a screen some content used on larger screens may still be width shrinks, the columns get skinnier. Once those loaded and taking up resources, even if hidden from columns are too small for their content to fit, they mobile users. However, for the sake of simplicity and stack vertically, with the later, right columns pushed wider familiarity with traditional desktop website below. This means it is important to keep elements in development, our demonstration will use a desktop- the same general order between each , as it is first approach. The process of applying responsive difficult to move content from a column that appears techniques to a desktop site can be easier to learn later in the HTML markup above earlier columns. and understand at first.

These wireframes show the layout transformations of a basic responsive website.

Developing a Responsive Website Set a Fluid

Once your responsive site mockups are ready, you will First up in the CSS, we frame our entire site with a also need to decide if you plan to develop your site fluid, wrapping container: mobile first. One of the main benefits of developing #page { the mobile version as the default website layout is width: 90%; improved performance. Since larger images and max-width: 960px; margin: 0 auto; } resource-intensive content is often only included for larger screens, developing mobile first allows By centering the site (margin:0 auto) and setting you to only load that content once it’s needed. If width:90%, this ensures that the site will always you start by developing the desktop version first,

4 WHITE PAPER / Designing for Mobile Websites using Responsive Design

have a 5% margin on either side, no matter the This will ensure ratios and proportions remain as browser width. This is important to prevent content intended, instead of just guessing at what percentage from pushing right up to the edge of browser width to use. For example, a 300px wide column screens and becoming more difficult to read. By inside of a 700px wide surrounding container setting max-width:960px, we are giving our in a mockup: website a maximum size, so widescreen monitors 300px / 700px = 0.42857 or 42.857% will still see a standard desktop website size, and maintain readable line-lengths. Set Margins

Within the wrapping container, each content div will Of course, we need some between these be floated and have a width set with percentages, content columns! But we also need to ensure our such as: total widths of elements next to each other stay under #LeftColumn { 100%. We could do: float: left; #LeftColumn { width: 70%; } width: 65%; #RightColumn { margin-right:5% } float: right; #RightColumn { width: 30%; } width: 30%; }

These two columns will fill the entire width of the So 65% + 5% + 30% = 100%. The margin size will also surrounding container at all times, since 70% + shrink and expand proportionately as the surrounding 30% = 100%. Don’t get confused because we set container size changes. the wrapping container to have a width of 90%. Percentage widths are always relative to their Set Media Sizes surrounding element – every div has a total available width of 100% within it, no matter the pixel size. Now Although responsive content areas are set using we have two content columns that will sit next to percentages, most included media, such as images, each other, expanding and contracting in width while will have pixel sizes associated with them. In order always keeping the same proportions and filling the to ensure media stays within the current size of its surrounding container. surrounding container, the following CSS should be included: We want to set up all sections of our site layout in img, object, embed, iframe, video { max-width:100%; } the same . Any content area of pixel-based mockup can easily be translated to percentages using This small bit of code can do a lot to make sure media a little math: stays properly aligned within your site. Target (px) / Context (px) = Result (%)

5 WHITE PAPER / Designing for Mobile Websites using Responsive Design

Make Changes with Media Queries @media (max-width:700px) { With our layout setup fluidly with percentages, and /*larger screen styles go here*/ } all content set to fill it dynamically, we should have a basic responsive site that will adjust as we shrink /* etc */ our browser. Of course, if our browser gets too small, At this stage in development, we begin to test and columns will start to get too skinny, menus will get review our website at increasingly smaller widths, out of line, and things will look broken. That’s where and make necessary adjustments to ensure things CSS media queries come in. work well and fit with our smaller mockups. One common adjustment is to stack content columns that Media queries serve different CSS based on your were previously next to each other, by setting 100% browser size or type. Media queries can target all widths, once they become too skinny: sorts of aspects of your browser, such as resolution and orientation, but for this demo we will simply be @media (max-width:600px) { targeting browser size using max-width. Media #LeftColumn { queries can be included directly in the main CSS file width: 100%; margin-right:0% } (put them at the end, since CSS is applied in the order #RightColumn { its written), so our CSS file will look something like this: width: 100%; } }

/* Desktop site CSS first */ Remember that media query breakpoints do not

@media (max-width:800px) { need to be set at any particular “standard” device /*tablet-specific styles go here*/ size, which is common within AWD. For example, } 320px and 480px have been popular breakpoints @media (max-width:600px) { since those are the portrait and landscape widths /*smaller tablet styles go here*/ of the Apple iPhone. However, if something looks } like it needs adjusting at 496px, then that’s where a @media (max-width:400px) { change should be made. Set media queries where /*mobile styles go here*/ } they are most needed!

If we were developing mobile-first, the CSS order We can also show and hide content using media would be opposite: queries. Using display:none in our CSS will remove content from view when it’s not needed, such as /* Mobile site CSS first */ hiding a large banner rotator in your mobile media

@media (min-width:500px) { query. As previously mentioned, it’s important to /*tablet-specific styles go here*/ remember that using does not } display:none

6 WHITE PAPER / Designing for Mobile Websites using Responsive Design

KNOW THIS…

It’s important to note that in Internet Explorer, media queries are only supported by version 9 and above. To support older versions of Internet Explorer, conditional comments can be used to link to Internet Explorer specific CSS, or a Javascript can be utilized (see Respond.js from Scott Jehl: https://github.com/scottjehl/Respond) generally help performance of the site, since Responsive Menu Options the content is usually still loaded and just hidden Menus can be one of the trickiest aspects of a from display. responsive website, but many different techniques and options have recently emerged. Basically any At this , it’s simply a matter of reviewing menu that is structured using unordered lists can be your website at different sizes and making CSS manipulated appropriately for smaller screen sizes.

The easiest option to modify a horizontal menu for smaller screen sizes is to switch it to a vertical menu. Horizontal list items that have a width set automatically for desktop browser sizes simply get a width of 100% set for mobile sizes, stacking vertically:

Regular CSS: nav ul li { The Springfield Clinic site adapts to from desktop/laptop float:left; viewports to mobile/tablet layout without compromising on width:auto; } content, navigation, legibility or aesthetic. Mobile-size CSS:

@media (max-width: 480px) { nav ul li { adjustments to improve usability along the way. float:none; Below is a real-world responsive site example (http:// width:100%; } } www.springfieldclinic.com): This tutorial also shows how to expand upon this

purely CSS technique to support menus with more

7 WHITE PAPER / Designing for Mobile Websites using Responsive Design

The markup:

Regular CSS:

.show-mobile { display: none; }

CSS to show the button and hide the menu for mobile: @media (max-width: 768px) { nav .show-mobile { display: block; } nav ul { display: none; } } than one : http://ejhansel.com/a-responsive- drop-down-navigation-menu. jQuery for the menu toggle:

Building upon that basic option, a vertical menu may

Web Analytics