Creating an app responsive design is crucial for a website's success, as it allows users to access and interact with your site seamlessly across various devices and screen sizes.
Responsive design is not just about making your website look good on different screens, but also about ensuring that it functions correctly and provides a consistent user experience.
A well-designed responsive website can increase engagement, reduce bounce rates, and ultimately drive more conversions.
By using a flexible grid system and relative units, designers can create a website that adapts to different screen sizes and devices, without sacrificing user experience or functionality.
Web Design Fundamentals
Responsive web design is the approach that suggests design and development should respond to the user's behavior and environment based on screen size, platform, and orientation.
It's a mix of flexible grids and layouts, images, and an intelligent use of CSS media queries that allows a website to automatically switch to accommodate for resolution, image size, and scripting abilities.
The idea is to eliminate the need for a different design and development phase for each new gadget on the market.
Ethan Marcotte wrote an introductory article about the approach, Responsive Web Design, for A List Apart.
Transplanting the discipline of responsive architectural design onto web design allows a website to automatically adjust to the user's preferences.
Responsive web design requires a more abstract way of thinking than using motion sensors and robotics, but it's already being practiced with features like fluid layouts, media queries, and scripts that can reformat web pages and mark-up effortlessly.
We can't keep creating custom solutions for each new device, so responsive web design is a whole new way of thinking about design.
It's not just about adjustable screen resolutions and automatically resizable images, but about a whole new way of thinking about design that adapts to the user's behavior and environment.
Responsive Design Principles
Responsive design principles are all about creating a website that automatically adjusts to the user's behavior and environment. This means designing for different screen sizes, platforms, and orientations.
The practice of responsive design consists of a mix of flexible grids and layouts, images, and intelligent use of CSS media queries. Ethan Marcotte's article on A List Apart introduced the concept of responsive web design, which is based on the idea of responsive architectural design.
A flexible layout is key to responsive design. Images can be automatically adjusted, and workarounds can be used so that layouts never break, although they may become squished and illegible in the process.
Here are some techniques for creating fluid images:
- Hiding and Revealing Portions of Images
- Creating Sliding Composite Images
- Foreground Images That Scale With the Layout
A good example of responsive design thinking is the logo in a design example, where the image is divided into two: one for the illustration and one for the name, to maintain its size and visibility.
Flexible Everything
Flexible layouts were once a luxury for websites, but now we can make them more flexible. Images can be automatically adjusted, and we have workarounds so that layouts never break.
We can create fluid grids, fluid images, and smart mark-up where needed. Ethan Marcotte's article featured a sample Web design that combines these features. Creating fluid grids is fairly common practice, and there are techniques for creating fluid images.
Some of these techniques include hiding and revealing portions of images, creating sliding composite images, and foreground images that scale with the layout. For more information, check out Zoe Mickley Gillenwater's book "Flexible Web Design: Creating Liquid and Elastic Layouts with CSS".
Here are some techniques for creating fluid images:
- Hiding and Revealing Portions of Images
- Creating Sliding Composite Images
- Foreground Images That Scale With the Layout
A good example of this is a logo that is divided into two parts: one for the illustration and one for the name. This way, the name remains visible even when the image is resized too small.
Pros and Cons
Responsive design takes significantly less work to create and maintain than adaptive design, both initially and ongoing.
One of the biggest advantages of responsive design is that it accommodates an infinite number of screen sizes, which is a good thing considering new devices with strange screen sizes are released regularly.
However, responsive websites require developers to do more coding, and even with close collaboration between UX designers and developers, it's impossible to control the layout on every single device.
A responsive site can be slower to load because the entire code is delivered no matter what device the site is accessed on, which can compromise the user experience.
Despite its limitations, responsive design is often the preferred solution for optimizing a website across devices, especially when creating a site from scratch with many webpages.
Adaptive design, on the other hand, can be easier for developers to implement and load faster because only the necessary code is delivered for the given screen size.
However, adaptive design can be a lot to take on for a UX designer, requiring them to design for multiple screen sizes and potentially limiting the work by designing for only a few common sizes.
Layout and Structure
As you design your app, consider using a custom layout structure that can adapt to different screen sizes. You can achieve this by defining a main style sheet with structural elements like #wrapper, #content, #sidebar, and #nav, along with colors, backgrounds, and typography.
Most styles can remain the same, while specific style sheets can inherit these styles and rearrange elements with floats, widths, and heights. This approach can be more efficient than creating a separate style sheet for each layout.
For extreme size changes, you can use a CSS media query to switch to a new style sheet that adopts everything from the default style sheet and redefines the layout's structure. This way, you can maintain consistency across different screen sizes.
Using percentages instead of pixel measurements makes content render well on devices with varying screen dimensions. This is especially important for creating flexible grids, which can be achieved with modern CSS layout techniques like Flexbox, Grid Layout, and Multicol.
You can improve the earlier floated example using Grid Layout and the fr unit, which represents a portion of the available space in the container. This creates flexible grids that can adapt to different screen sizes.
For some types of layout, you can use Multiple-column Layout (Multicol), which creates responsive numbers of columns with the column-width property. This can be useful for adding columns when there's room for another 200px column.
To provide a good user experience, it's essential to size content to the viewport. This means adjusting your content to fit inside the specified viewport, rather than forcing the user to scroll horizontally or zoom out to see the whole page.
Responsive Design Techniques
Responsive design techniques are essential for creating a seamless user experience across various devices and screen sizes.
Media queries are a powerful tool for responsive design, allowing you to apply specific styles based on device features such as width, height, orientation, and touchscreen capabilities.
Use media queries to include print styles in your main style sheet, and customize your layout for touchscreens or smaller screens.
Media queries can test for various screen size features, including width, height, orientation, and aspect-ratio, with excellent browser support.
Flexbox is ideal for displaying items of different sizes in a row or multiple rows, with smaller items taking up less space and larger ones taking more space.
CSS Grid Layout creates flexible grids, allowing you to improve floated layouts and create regular grid layouts with as many items as can fit.
The key to choosing breakpoints is to let the content determine how its layout changes to fit the container, rather than defining them based on device classes or product names.
To pick major breakpoints, start by designing the content to fit on a small screen size first, then expand the screen until a breakpoint becomes necessary.
Here's a step-by-step guide to inserting a breakpoint at 600px:
- Make the forecast look good on a small screen.
- Resize the browser until there's too much whitespace between the elements to make the widget look good (more than 600px is certainly too wide).
- Create two media queries at the end of your CSS for the component: one to use when the browser is 600px or narrower, and one for when it's wider than 600px.
- Refactor the CSS. Inside the media query for a max-width of 600px, add the CSS which is only for small screens. Inside the media query for a min-width of 601px add CSS for larger screens.
By following these best practices, you can create a responsive design that adapts to different screen sizes and devices, providing a better user experience.
Breakpoints and Viewport
Breakpoints are crucial in responsive design, and they're based on the viewport size. The viewport is the visible area of the screen, and it's usually around 980px, but it can vary across devices.
To set the viewport, you need to include a meta viewport tag in the head of your document. This tag tells the browser how to control the page's dimensions and scaling. Using the meta viewport value width=device-width tells the page to match the screen's width in device-independent pixels.
You can also use media queries to create a responsive experience that applies specific styles to specific screen sizes. Queries for screen size can test for width, height, orientation, and aspect-ratio.
To choose breakpoints, don't define them based on device classes or any product, brand name, or operating system. Instead, let the content determine how its layout changes to fit the container. Start by designing the content to fit on a small screen size first, then expand the screen until a breakpoint becomes necessary.
Here are some common media query features:
- width (min-width, max-width)
- height (min-height, max-height)
- orientation
- aspect-ratio
Pick major breakpoints by starting small, then working up. For example, if you have a weather forecast widget, make it look good on a small screen first, then expand the screen until there's too much whitespace between the elements. You can insert a breakpoint at 600px, for instance.
You can also use minor breakpoints to adjust for minor changes, such as increasing the font size or adjusting margins and padding. For instance, between major breakpoints, you can boost the font when the viewport width is greater than 360px.
To view your media query breakpoints in Chrome DevTools, open DevTools, turn on Device Mode, and select Show media queries. This will show your breakpoints as colored bars above your page.
Optimizing Content
Optimizing Content is crucial for a great user experience. It's not just about making everything fit on a smaller screen, but also about providing a clear and focused experience for the user.
Simpler navigation and more focused content are essential for mobile environments. We can achieve this by hiding content on smaller screens and replacing it with navigation to that content, or with a different navigation structure altogether.
It's essential to use the display property to get rid of content altogether, rather than just hiding it with the visibility property. This saves resources and prevents unnecessary scrolling or layout breaks.
For smaller devices, there's no need to keep the markup on the page, as it just takes up resources and might cause problems. We can use a script or alternate style sheet to increase white space or replace image navigation sources on mobile devices for better usability.
Classic readability theory suggests that an ideal column should contain 70 to 80 characters per line. We can add a breakpoint every time the width of a text block grows past about 10 words to optimize text for reading.
In fact, the Roboto font at 1em produces 10 words per line on smaller screens, but larger screens need a breakpoint. For example, if the browser width is greater than 575px, the ideal content width is 550px.
Design and Development
Responsive web design is the approach that suggests design and development should respond to the user's behavior and environment based on screen size, platform, and orientation. This means the website should automatically adjust to accommodate different screen sizes, image sizes, and scripting abilities.
The practice consists of a mix of flexible grids and layouts, images, and an intelligent use of CSS media queries. This allows the website to adapt to different devices, such as switching from a laptop to an iPad.
Ethan Marcotte introduced the concept of responsive web design in an article for A List Apart, drawing inspiration from responsive architectural design. Architects don't design a building for each group size and type that passes through it, so why should we create a custom web design for each group of users?
Responsive web design requires a more abstract way of thinking, but some ideas are already being practiced, such as fluid layouts, media queries, and scripts that can reformat web pages and mark-up effortlessly. This allows for a more dynamic and adaptable design.
Custom solutions for each new device are no longer feasible, so responsive web design is the way to go. It's a whole new way of thinking about design, considering adjustable screen resolutions and automatically resizable images.
Frequently Asked Questions
What is the difference between PWA and responsive design?
A Progressive Web App (PWA) provides a native-like experience with features like offline work and push notifications, whereas a responsive web app focuses on a seamless display experience. The key difference lies in their approach to user experience and functionality.
Sources
- https://www.smashingmagazine.com/2011/01/guidelines-for-responsive-web-design/
- https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Responsive_Design
- https://en.wikipedia.org/wiki/Responsive_web_design
- https://web.dev/articles/responsive-web-design-basics
- https://careerfoundry.com/en/blog/ui-design/responsive-vs-adaptive-design/
Featured Images: pexels.com