Код: Выделить всё
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "navbar") {
x.className += " responsive";
} else {
x.className = "navbar";
}
}
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.navbar {
overflow: hidden;
background-color: #333;
border-radius: 5px;
}
.navbar a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.navbar .icon {
display: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font: inherit;
margin: 0;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
width: 60%;
left: 0;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
border-radius: 10px;
}
.navbar .dropdown>.dropdown-content {
left: 50%;
transform: translate3d(-50%, 10px, 0);
}
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.navbar a:hover,
.dropdown:hover .dropbtn {
background-color: #555;
color: white;
}
.dropdown-content a:hover {
background-color: #ddd;
color: black;
}
.dropdown:hover .dropdown-content {
display: block;
}
@media screen and (max-width: 992px) {
.navbar a:not(:first-child),
.dropdown .dropbtn {
display: none;
}
.navbar a.icon {
float: right;
display: block;
}
}
/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 33.33%;
padding: 10px;
background-color: #fff;
height: 250px;
border-radius: 10px;
}
.column a {
float: none;
color: black;
padding: 16px;
text-decoration: none;
display: block;
text-align: left;
}
.column a:hover {
background-color: #eff;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
@media screen and (max-width: 992px) {
.navbar.responsive {
position: relative;
}
.navbar.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.navbar.responsive a {
float: none;
display: block;
text-align: left;
}
.navbar.responsive .dropdown {
float: none;
}
.navbar.responsive .dropdown-content {
position: relative;
}
.navbar.responsive .dropdown .dropbtn {
display: block;
width: 100%;
text-align: left;
}
.column {
width: 100%;
height: auto;
}
}
[url=#home]Home[/url]
[url=#news]News[/url]
[url=#news]News[/url]
[url=#news]News[/url]
[url=#news]News[/url]
Dropdown [i][/i]
Category 1
[url=#]Link 1[/url]
[url=#]Link 2[/url]
[url=#]Link 3[/url]
Category 2
[url=#]Link 1[/url]
[url=#]Link 2[/url]
[url=#]Link 3[/url]
Category 3
[url=#]Link 1[/url]
[url=#]Link 2[/url]
[url=#]Link 3[/url]
[url=#news]News[/url]
[url=#news]News[/url]
Dropdown [i][/i]
Category 1
[url=#]Link 1[/url]
[url=#]Link 2[/url]
[url=#]Link 3[/url]
Category 2
[url=#]Link 1[/url]
[url=#]Link 2[/url]
[url=#]Link 3[/url]
Category 3
[url=#]Link 1[/url]
[url=#]Link 2[/url]
[url=#]Link 3[/url]
[url=javascript:void(0);]
[i][/i]
[/url]
Подробнее здесь: https://stackoverflow.com/questions/793 ... nav-button
Мобильная версия