<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<script src="scrips.js"></script>
<div class="wrapper">
<header class="header">
<head class="header_container">
<a href="#"class="logo"></a>
<div class="header_menu menu">
<div class="menu_icon">
<span></span>
</div>
<nav class="menu_body">
<ul class="menu_list">
<li><a href="#"class="menu_link">Раздел 1</a></li>
<li><a href="#"class="menu_link">Раздел 2</a></li>
<li><a href="#"class="menu_link">Раздел 2</a></li>
<li><a href="#"class="menu_link">Страница 1</a>
<span class="menu_arrow"></span>
<ul class="menu_sub-list">
<li><a href="#"class="menu_sub-link">hi</a></li>
<li><a href="#"class="menu_sub-link">hello</a></li>
<li><a href="#"class="menu_sub-link">hey</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</head>
</header>
<main class="page">
<section class="page_saction">
<h1>qqqqqqqqqqqqqqqqqqqqqqq</h1>
</section>
</main>
</div>
</body>
</html>
body {
padding: 0;
margin: 0;
font-family: 'Open Sans', sans-serif;
font-size: 16px;
color: #000;
-webkit-font-smoothing: antialiased;
background-color: #F8F8F8;
}
*,
*:before,
*:after {
box-sizing: border-box;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0;
padding: 0;
}
p {
margin: 0;
padding: 0;
}
hr {
margin: 0;
padding: 0;
}
ul,
li {
display: block;
padding: 0;
margin: 0;
}
a {
text-decoration: none;
}
.header {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 10;
background-color: #246;
}
.header_container {
max-width: 1200px;
margin: 0px auto;
display: flex;
padding: 0px 30px;
align-items: center;
justify-content: space-between;
min-height: 70px;
}
.logo {
border-radius: 50%;
background-color: #fff;
position: relative;
z-index: 5;
width: 40px;
height: 40px;
}
.header_menu {
}
.menu {
}
.menu_icon {
}
.menu_body {
}
.menu_list {
}
.menu_list > li {
position: relative;
margin: 0px 0px 0px 20px;
}
.menu_link {
color: #fff;
font-size: 18px;
}
.menu_link:hover{
text-decoration: underline;
}
.menu_sub-list {
position: absolute;
top: 100%;
right: 0;
background-color: #000;
padding: 15px;
min-width: 200px;
}
.menu_sub-list li {
margin: 0px 0px 10px 0px;
}
.menu_sub-list li:last-child {
margin: 0;
}
.menu_sub-link {
color: #fff;
}
.menu_sub-link:hover{
text-decoration: underline;
}
.menu_arrow {
display: none;;
}
/* --------------------------- */
body._pc .menu_list > li:hover .menu_sub-list {
opacity: 1;
visibility: visible;
transform: translate(0px, 0px);
pointer-events: all;
}
body._touch .menu_list > li {
display: flex;
align-items: center;
}
body._touch .menu_link {
flex: 1 1 auto;
}
body._touch .menu_arrow {
display: block;
width: 0;
height: 0;
margin: 0px 0px 0px 5px;
transition: transform 0.3s ease 0s;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 10px solid #fff;
}
body._touch .menu_list > li._active .menu_sub-list {
opacity: 1;
visibility: visible;
transform: translate(0px, 0px);
pointer-events: all;
}
/* --------------------------- */
@media (min-width: 767px) {
.menu_list {
display: flex;
align-items: center;
}
.menu_list > li {
padding: 10px 0;
}
.menu_sub-list {
transform: translate (0px, 10%);
opacity: 0;
visibility: hidden;
pointer-events: none;
}
}
"use strict"
var isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function () {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function () {
return navigator.userAgent.match(/IEMobile/i);
},
any: function () {
return (
isMobile.Android()
|| isMobile.BlackBerry()
|| isMobile.iOS()
|| isMobile.Opera()
|| isMobile.Windows()
);
}
};
if (isMobile.any()) {
document.body.classList.add('_touch');
let menuArrows = document.querySelectorAll('.menu_arrow');
if (menuArrows.length > 0) {
for (let index = 0; index < menuArrows.length; index++) {
const menuArrow = menuArrows[index];
menuArrow.addEventListener("click", function (e) {
menuArrow.parentElement.classList.toggle('_active');
});
}
}
} else {
document.body.classList.add('_pc');
}
<nav class="menu">
<div class="container">
<ul class="topmenu">
<li><a href="" class="a">рекламная продукция</a>
<ul class="submenu">
<li><a href="">Визитки</a></li>
<li><a href="">Листовки</a></li>
<li><a href="">Многостраничные изделия</a></li>
<li><a href="">Плакаты</a></li>
<li><a href="">Упаковка</a></li>
<li><a href="">Конверты</a></li>
<li><a href="">Папки</a></li>
<li><a href="">Календари</a></li>
<li><a href="">Пакеты</a></li>
<li><a href="">Календарные сетки</a></li>
<li><a href="">СТР формы</a></li>
<li><a href="">Изделия нестандартных размеров</a></li>
</ul>
</li>
<li><a href="" class="a">картонная упаковка</a></li>
<li><a href="" class="a">флексо печать</a></li>
<!-- <li><a href="" class="a">Производственные мощности</a></li> -->
<li><a href="" class="a">контакты</a></li>
<li><a href="" class="a">о нас</a></li>
</ul>
</div>
</nav
.menu {
background: #184fa3;
/* text-align: center; */
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
}
.topmenu {
justify-content: space-between;
flex-wrap: wrap;
display: flex;
flex-direction: row;
}
nav a {
display: block;
text-align: center;
text-decoration: none;
transition: .2s linear;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
}
.active {
/* font-weight: bold; */
}
.topmenu > li {
text-align: center;
display: inline-block;
position: relative;
}
.topmenu > li > a {
width: 100%;
height: auto;
text-transform: uppercase;
color: #fff;
}
.a {
font-weight: 500;
padding: 15px 0;
}
.active:after, .submenu-link:after {
color: inherit;
}
.topmenu, .topmenu > li > a:hover {color: #fff;}
.submenu li a:hover {color: #DA1111}
.submenu {
position: absolute;
z-index: 5;
width: 300px;
border: 1px solid #184fa3;
box-sizing: border-box;
box-shadow: 0px 4px 5px rgba(1, 102, 174, 0.22);
visibility: hidden;
opacity: 0;
transform: translateY(10px);
transition: .3s ease-in-out;
}
.submenu li {position: relative; }
.submenu a {
background: #fff;
color: #1c1c1c;
text-align: left;
font-weight: 500;
font-size: 16px;
padding: 10px 20px;
}
.submenu .submenu {
position: absolute;
top: 0;
}
nav li:hover > .submenu {
visibility: visible;
opacity: 1;
transform: translateY(0px);
}