Web design standards: everything you need to know for beginners and pros
How do design standards increase website popularity? There is an opinion that web design standards attract users to sites, and most importantly - keep them for a long time. Why?…

Continue reading →

What is a selling design?
Design is the most important component of any website. This is especially true for selling sites, because in this case it is necessary to interest the visitor and encourage him…

Continue reading →

The Importance of Visual Context in Web Design
From the author: According to the results of a popular study by the University of Missouri Science and Technology, visitors form an opinion about your business site in less than…

Continue reading →

Layout adaptive menu

Adaptive menus collapsing into a hamburger on mobile devices can now be seen on almost any site. In this lesson we will learn to make up such menus. In the end, we should get the result shown below:
Menu for large screens
First, we make up the usual menu for the “large” resolution (in our case, this will be a screen resolution of 1000px or more). To do this, create the following HTML structure:

Markup
<div class = “menu”>
<div class = “menu__links”>
<a class=”menu__links-item” href=”/”> Item 1 </a>
<a class=”menu__links-item” href=”/”> Item 2 </a>
</div>
</div>
And add the necessary styles:

CSS
.menu {
text-align: right;
}

.menu__links-item {
display: inline-block;
color: # 333333;
font-family: Arial;
font-size: 14px;
line-height: 30px;
padding: 0 10px;
text-transform: uppercase;
text-decoration: none;
}

.menu__links-item: hover {
text-decoration: underline;
}
So far, everything is simple. We added two menu items and styled them as we needed.

Adaptation for mobile devices
In the second step, we need to add a hamburger icon and make the menu on mobile devices open by clicking on this icon. Screens larger than 1000px should display a regular menu.

In the HTML structure, add the icon:

Markup
<div class = “menu__icon”>
<span> </span>
<span> </span>
<span> </span>
<span> </span>
</div>
And write styles for her:

CSS
.menu__icon {
display: none;
width: 45px;
height: 35px;
position: relative;
cursor: pointer;
}

.menu__icon span {
display: block;
position: absolute;
height: 9px;
width: 100%;
background: # 333333;
border-radius: 9px;
opacity: 1;
left: 0;
transform: rotate (0deg);
transition: .25s ease-in-out;
}

.menu__icon span: nth-child (1) {
top: 0px;
}

.menu__icon span: nth-child (2), .menu__icon span: nth-child (3) {
top: 13px;
}

.menu__icon span: nth-child (4) {
top: 26px;
}
Pay attention to the rule display: none; for the .menu__icon class – by default the icon should not be visible.

For small screens, we’ll add additional rules: firstly, we need to show the icon, secondly, to refine the styles and hide the menu, and thirdly, add styles for menu items:

CSS
@media screen and (max-width: 999px) {
.menu__icon {
display: inline-block;
}

.menu__links {
position: fixed;
display: block;
top: 0;
right: 0;
left: 0;
margin-top: 52px;
background-color: rgba (0, 0, 0, 0.8);
z-index: 1000;
overflow: auto;
}

.menu__links-item {
display: block;
padding: 10px 0;
text-align: center;
color: #ffffff;
}
}
Now the layout of the menu works as it should, the last step remains – to show the menu when you click on the icon.

Menu logic implementation
To show the menu when you click on the icon, add some JavaScript’s.

Javascript
(function ($) {
$ (function () {
$ (‘. menu__icon’). on (‘click’, function () {
$ (this) .closest (‘. menu’). toggleClass (‘menu_state_open’);
});
});
}) (jQuery);
For simplicity, we used jQuery, but if you want, you can implement the same logic in your framework or in pure JavaScript. In the code above, we just switch the .menu_state_open class of the .menu element when we click on the icon.

Finally, add styles for the open state of the menu:

CSS
.menu.menu_state_open .menu__icon span: nth-child (1) {
top: 18px;
width: 0%;
left: 50%;
}

.menu.menu_state_open .menu__icon span: nth-child (2) {
transform: rotate (45deg);
}

.menu.menu_state_open .menu__icon span: nth-child (3) {
transform: rotate (-45deg);
}

.menu.menu_state_open .menu__icon span: nth-child (4) {
top: 18px;
width: 0%;
left: 50%;
}

.menu.menu_state_open .menu__links {
display: block;
}
For the menu to be open, we set the width of the upper and lower hamburger strip to zero, and rotate the two middle ones 45 degrees so that they form a cross (which is why the central strip is formed by two span elements located one above the other).

In the current version, links in the menu have the href attribute and lead to a new page. But such a menu can work without reloading the page, for this you need to add a click handler on the link, perform some action in this handler and remove the .menu_state_open class from the .menu element:

Conclusion
In this lesson we made up an adaptive menu that collapses into a hamburger on small screens. Depending on the design requirements, you can style it as you wish, but the general principle will remain the same.

Web Design 2016: Chrome attacks!
From the author: The year 2016 has ended, it is always interesting to go back and see how much the workflow has improved over the previous 12 months. It's amazing…

...

Rubber web design. What and where are we going to stretch?
When developing a website, the webmaster, first of all, should be based on the goals of the project. If it is important for the customer that the web page can…

...

Basic web design elements. How to create an effective website thanks to them?
For the construction of any building requires certain building materials. As a rule, for each type of structure they constantly remain the same, only the shape and general design of…

...

The Importance of Visual Context in Web Design
From the author: According to the results of a popular study by the University of Missouri Science and Technology, visitors form an opinion about your business site in less than…

...