Adaptive layout using html5 and css3. Video course “Adaptive layout in HTML5 and CSS3. Styles for the main content block

Adaptive website layout allows web pages to automatically adjust to the screens of tablets and smartphones. Mobile Internet traffic is growing every year, and in order to effectively process this traffic, you need to offer users responsive websites with a user-friendly interface.

Search engines use a number of criteria to evaluate a site's responsiveness when viewed on mobile devices. Google is trying to simplify the use of the Internet for owners of smartphones and tablets by marking sites adapted for mobile devices with a special mark mobile-friendly in mobile search results. Yandex also has an algorithm that gives preference to sites with a mobile/responsive version for users in mobile search.

You can check the display of the page on mobile devices on the services and.

Rice. 1. Mobile search results from Yandex and Google with a note about the site’s friendliness to mobile devices. What is adaptive layout?

Adaptive layout assumes the absence of a horizontal scroll bar and scalable areas when viewed on any device, readable text and large areas for clickable elements. Using media queries, you can control the layout and placement of blocks on a page, rearranging the template so that it adapts to different device screen sizes.

Basic techniques for creating a responsive website are given in the article. For responsive design, the width of the main site container is set in %, and it can be equal to 100% of the browser window width or less. The width of the grid columns is also specified in %. In responsive design, the width of the main container and grid columns is fixed using px values.

The adaptive fluid layout technique discussed in this lesson will work perfectly on a two-column template, making the site adaptive and convenient for viewing on mobile devices. The template assumes a different layout of the main content of the pages; in this lesson the layout of the main page will be discussed.

Home page layout

A page consists of three main blocks: a header (header), a wrapper container for the main content and sidebar, and a footer (footer). Let's take 768px and 480px as design turning points.

At the first point, we will hide the top menu and move the sidebar under the container with posts. At the second point, we will change the location of the header elements, cancel the positioning of social network buttons in posts, and cancel the wrapping of the page footer columns.


Rice. 2. Example of adaptive layout 1. Meta tags and section

1) Add the necessary files to the section - a link to the fonts used, the jQuery library, as well as the prefixfree plugin (so as not to write browser prefixes for properties):

Adaptive website layout

2. Page header

We will place the following container elements in the page header:
logo