Translation of the article “Responsive Web Design: What It Is And How To Use It”
Adaptive layout changes page design depending on user behavior, platform, screen size and device orientation and is an integral part of modern web development. It allows you to save significantly and not have to draw a new design for each resolution, but change the size and location of individual elements.
This article will look at the main elements of the site and how to adapt them.
Adjusting screen resolution
In principle, you can divide devices into different categories and design for each of them separately, but this will take too much time, and who knows what standards will be in five years? Moreover, according to statistics, we have a whole range of different resolutions:
It becomes obvious that we will not be able to continue to design for each device separately. But what to do then?
Partial solution: make everything flexible
Of course, this is not a perfect method, but it eliminates most of the problems.
Ethan Marcotte created a simple template demonstrating the use of responsive layout:
The entire design is a mix of responsive layers, images and, in some places, smart markup. Creating adaptive layers is a common practice, which cannot be said about adaptive images. However, if you need them, consider the following techniques:
- Hiding and Revealing Portions of Images;
- Creating Sliding Composite Images;
- Foreground Images That Scale With the Layout.
For more detailed information, we recommend that you read Zoe Mickley Gillenwater's book “Flexible Web Design: Creating Liquid Layouts with CSS” and download the chapter “Creating Flexible Images”.
Backend developer (Laravel)
WHITE RUSSIAN, Moscow, from 180,000 to 250,000 ₽
tproger.ru
Jobs on tproger.ru
At first glance it may seem that everything is easy, but it is not. Take a look at the logo:
If you reduce the entire image, the inscriptions will become unreadable. Therefore, in order to save the logo, the picture is divided into two parts: the first part (illustration) is used as a background, the second (logo) changes its size proportionally.
The h1 element contains an image as the background, and the image is aligned to the background of the container (header).
Flexible images
Working with images is one of the biggest challenges when working with responsive design. There are many ways to resize images, and most of them are quite simple to implement. One solution is to use max-width in CSS:
img {max-width: 100%;}
The maximum width of an image is 100% of the width of the screen or browser window, so the smaller the width, the smaller the image. Note that max-width is not supported in IE, so use width: 100%.
The presented method is a good option for creating adaptive images, but by changing only the size, we will leave the weight of the image the same, which will increase the loading time on mobile devices.
Another way: responsive images
The technique, introduced by Filament Group, not only resizes images, but also compresses the resolution of images on small screens to speed up loading.
This technique requires several files available on Github. First we take the JavaScript file (rwd-images.js), the .htaccess file and the rwd.gif (image file). Then we use some HTML to link the large and small resolutions: first a small image with a .r prefix (to indicate that the image should be responsive), then a link to the large image using data-fullsrc:
For any screen wider than 480 px, a higher resolution image will be loaded ( largeRes.jpg
), and on small screens it will load (
smallRes.jpg
).
Interesting feature for iPhone
The iPhone and iPod Touch have a feature: a design created for large screens will simply shrink in a low-resolution browser without scrolling or additional mobile layout. However, images and text will not be visible:
To solve this problem, use the meta tag:
If initial-scale is equal to one, the width of the images becomes equal to the width of the screen.
Customizable page layout structure
For significant changes in page size, you may need to change the overall arrangement of elements. This can be conveniently done through a separate styles file or, more efficiently, through a CSS media query. There shouldn't be any problems as most of the styles will remain the same and only a few will change.
For example, you have a main style file that specifies #wrapper, #content, #sidebar, #nav along with colors, background and fonts. If your master styles make your layout too narrow, short, wide, or tall, you can identify this and include new styles.
style.css (main):
/* Basic styles that will be inherited by the child style sheet */ html,body{ background... font... color... } h1, h2, h3{} p, blockquote, pre, code, ol, ul{} /* Structural elements */ #wrapper{ width: 80%; margin: 0 auto; background: #fff; padding: 20px; } #content{ width: 54%; float: left; margin-right: 3%; } #sidebar-left{ width: 20%; float: left; margin-right: 3%; } #sidebar-right{ width: 20%; float: left; }
mobile.css (child):
#wrapper{ width: 90%; } #content{ width: 100%; } #sidebar-left{ width: 100%; clear: both; /* Additional styles for the new design */ border-top: 1px solid #ccc; margin-top: 20px; } #sidebar-right{ width: 100%; clear: both; /* Additional styling for our new layout */ border-top: 1px solid #ccc; margin-top: 20px; }
On a wide screen, the left and right sidebars fit nicely to the side. On narrower screens, these blocks are located one below the other for greater convenience.
CSS3 media queries
Let's look at how you can use CSS3 media queries to create responsive designs. min-width specifies the minimum width of the browser window or screen to which certain styles will be applied. If any value is below min-width, the styles will be ignored. max-width does the opposite.
Example:
@media screen and (min-width: 600px) { .hereIsMyClass { width: 30%; float: right; } }
The media query will only work when the min-width is greater than or equal to 600 px.
@media screen and (max-width: 600px) { .aClassforSmallScreens { clear: both; font-size: 1.3em; } }
In this case, the class (aClassforSmallscreens) will work when the screen width is less than or equal to 600 px.
While min-width and max-width can apply to both screen width and browser window width, we may only need to work with device width. For example, to ignore browsers opened in a small window. You can use min-device-width and max-device-width for this:
@media screen and (max-device-width: 480px) { .classForiPhoneDisplay { font-size: 1.2em; } } @media screen and (min-device-width: 768px) { .minimumiPadWidth { clear: both; margin-bottom: 2px solid #ccc; } }
Especially for iPad, media queries have an orientation property, the values of which can be either landscape (horizontal) or portrait (vertical):
@media screen and (orientation: landscape) { .iPadLandscape { width: 30%; float: right; } } @media screen and (orientation: portrait) { .iPadPortrait { clear: both; } }
You can also combine media query values:
@media screen and (min-width: 800px) and (max-width: 1200px) { .classForaMediumScreen { background: #cc0000; width: 30%; float: right; } }
This code will only be executed for screens or browser windows between 800 and 1200 px wide.
You can load a specific sheet with styles for different media query values like this:
JavaScript
If your browser does not support CSS3 media queries, then style replacement can be done using jQuery:
$(document).ready(function(){ $(window).bind("resize", resizeWindow); function resizeWindow(e){ var newWindowWidth = $(window).width(); // If the width is less than 600 px , the mobile style sheet is used if(newWindowWidth
< 600){ $("link[rel=stylesheet]").attr({href : "mobile.css"}); } else if(newWindowWidth > 600){ // If width is greater than 600 px, a desktop style sheet is used $("link[rel=stylesheet]").attr({href : "style.css"}); } } });
Optional content display
The ability to shrink and rearrange elements to fit on small screens is great. But this is not the best option. Mobile devices typically feature a broader set of changes: simplified navigation, more focused content, lists or rows instead of columns.
Luckily, CSS gives us the ability to show and hide content with incredible ease.
display: none;
display: none is used for objects that need to be hidden.
Example:
Here's our markup:
Left Sidebar Content | Right Sidebar Content
How to make a website responsive on all screens?
To make a website responsive on a mobile or desktop device, you need to have an understanding of HTML5, CSS3 and JavaScript. In addition to general knowledge, you need to understand the basic principles of adaptability.
Only with them you can start making website layout:
- Threading is the principle of no displacement of information blocks when viewing a site from a mobile device.
- Relativity in measurement is the principle of using relative units to set the size and coordinates of the upper and lower boundaries of a block of a PC screen and smartphone display.
- The use of breakpoints is the principle of arranging elements for different screens to avoid shifting the content of site pages.
- The principle of competent use of minimum and maximum values . For example, if the screen is less than 1000 pixels wide, then the content is placed on the entire screen. Otherwise, the maximum width will reach 1000 pixels.
- The principle of nesting objects to prevent the complexity of controlling different elements of the site. You can put them in one container. Required for those blocks that do not need to be adapted to the screen - buttons with logos, etc.
- Use the same fonts to avoid site overload.
- Correct use of raster and vector graphics . For example, if a picture consists of many details, you should make it in a raster format and, conversely, if there is only one, then it is better to use a vector format. However, it is worth remembering about compression. Each image must be optimized for new browsers.
- Compliance with model dimensions and general website layout standards. The following resolutions are considered standard, at which the design does not change and the site does not display correctly:
- for mobile devices – 320px, 480 px;
- for tablet computers – 768px;
- for netbooks with some tablets – 1024px;
- for PC – 1280px and more.
Video instructions: How to make a responsive website in Photoshop.
Mobile version of the site or adaptability? What is the difference? Advantages and disadvantages.
To understand the differences between these terms, let's find out what the difference is between them.
The mobile version of the site is a separate version of the site, created and aimed specifically at users with smartphones or tablets. As a rule, it differs from the PC version in reduced functionality for faster loading while preserving all the main blocks of the site. Most often they are located on subdomains such as m.name.ru, mobile.name.com. You can see an example by logging into the social network VKontakte through a mobile device (*! not an application, but through a mobile browser! *).
Advantages:
- easy change of content and code, since the mobile version in 95% of cases is not related to the main part;
- loading speed, thanks to the lighter weight of the same photos and the same functionality;
- ease of use by the user arising from the above advantages;
- the ability to present information sites such as a news portal without altering the code and structure of the site. This is especially true on those sites that have existed for a long time and technology may not allow adaptability to be implemented;
- possibility of choice. The decision to automatically switch the site to the mobile version is determined using the MAC address of the device and the IP address. If the user needs the functionality of the desktop version, then, as a rule, he can switch to it by going to the main (full) version of the site.
Flaws:
- a relative disadvantage related to the behavioral factor is the presence of several addresses for different versions (tablet, mobile devices, PC version). Some people won’t care, and some people may not like the fact that when switching from the PC version to the mobile version, you will have to wait again for the page to load;
- some difficulties for SEO promotion, since if the combination of the mobile and full versions of the site is incorrectly configured, the search system may begin to complain about duplication of information, which will significantly reduce the site’s position in organic results.
- limitation. If you repeat the functionality and content of the full version, it will take a long time to load and will result in user dissatisfaction with too long a waiting time. If you make the information part minimal, the loading speed will be high, and the user may not understand many points due to lack of information. The ideal solution in this case is a reasonable and optimal combination and compromise between loading speed and output information.
Desert, semi-desert, steppe adaptive type
The desert, semi-desert, steppe adaptive type is formed in a hot, dry, sharply continental climate with intense solar radiation. This type is characterized by increased heat generation, well-developed sweat glands, and abundant water consumption. The majority of the population of Central Asia belongs to this adaptive type.
Categories: Human ecology Adaptation
On this page there is material on the following topics:
Desert geographical group of people
Tropical group of people
Residents of which countries belong to the mountain adaptive type
Gecnyssq nbg xtkjdtrf
High-horned type of people
Questions for this article:
What are adaptive human types?
Checking website adaptability
To check the site’s adaptability settings and its correct display on all devices, you can use a browser or a special Google Mobile Friendly service (Google Search Console).
You can check it with the Google browser by holding F12 and selecting “Additional tools” and “Developer tools” from the menu. You can also do this through Mozilla Firefox: F12 -> Menu -> Development -> Responsive Design.
Through the Google service, you can test adaptability using the link https://search.google.com/test/mobile-friendly.
In general, making a website responsive is not difficult. The main thing is to understand the principles of adaptability and be able to correctly set the basic Internet settings to create it.
Arctic adaptive type
The Arctic adaptive type is formed in cold climates, where animal products predominate in the diet. In the digestive system of the peoples of the Arctic, adaptations have been developed that are associated with insufficient consumption of vitamin C in plants. Characteristic features of the Arctic adaptive type are a well-developed musculoskeletal system and a higher content of proteins and fats in the blood. A higher level of energy metabolism and the development of the ability to thermoregulate are also characteristic of the Arctic type.