Я скопировал некоторый код вокруг интернета и придумал панель навигации, которая мне нравится. Единственная проблема, при открытии меню текст внутри странно перекрывается. есть способ исправить это? (смотреть в полноэкранном режиме) T
Текст представляет собой отдельные контейнеры внутри другого контейнера, который затем открывается в сторону. я думаю, поэтому текст складывается.
/*bar animation bar to cross*/
function myFunction(x) {
x.classList.toggle("change");
}
/*bar animation bar to cross*/
function myFunction(x) {
x.classList.toggle("change");
document.getElementById("mySidenav").classList.toggle('open');
}
// When the user scrolls down 80px from the top of the document, resize the navbar's padding and the logo's font size
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) {
document.getElementById("header").style.padding = "30px 10px";
document.getElementById("title").style.fontSize = "40px";
} else {
document.getElementById("header").style.padding = "80px 10px";
document.getElementById("title").style.fontSize = "130px";
}
}
#header {
overflow: hidden;
background-color: #FFFFFF;
padding: 50px 10px;
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.2);
transition: 0.4s;
position: fixed; /* Sticky/fixed navbar */
/*outline: 5px dashed orange;*/
width: 100%;
top: 0px;
left: 0px;
right: 0px;
z-index: 99;
}
/* Style the header links */
#header a {
float: left;
color: black;
text-align: center;
padding-top: 12px;
padding-right: 12px;
padding-left: 12px;
padding-bottom: 12px;
text-decoration: none;
font-family: lato;
font-size: 18px;
line-height: 25px;
border-radius: 4px;
/*outline: 5px dashed yellow;*/
}
#navplusicon{
margin-right: 30px;
}
.navicon {
margin-top: 1vw;
/*outline: 5px dashed green;*/
position: sticky;
}
.menu_bar_icon {
display: inline-block;
cursor: pointer;
}
.bar1, .bar2, .bar3 {
width: 20px;
height: 2px;
background-color: #000000;
margin: 4px 0;
transition: 0.4s;
}
/* Rotate first bar */
.change .bar1 {
-webkit-transform: rotate(-45deg) translate(-4px, 3px) ;
transform: rotate(-45deg) translate(-4px, 3px) ;
}
/* Fade out the second bar */
.change .bar2 {
opacity: 0;
}
/* Rotate last bar */
.change .bar3 {
-webkit-transform: rotate(45deg) translate(-5px, -4px) ;
transform: rotate(45deg) translate(-5px, -4px) ;
}
/* The side navigation menu */
.sidenav {
float: right;
height: 10px; /* 100% Full-height */
width: 30px; /* 0 width - change this with JavaScript */
z-index: 1; /* Stay on top */
top: 0; /* Stay at the top */
overflow-x: hidden; /* Disable horizontal scroll */
overflow-y: hidden;
padding-top: 50px; /* Place content 60px from the top */
transition: 0.5s; /* 0.5 second transition effect to slide in the sidenav */
/*outline: 5px dashed blue;*/
}
/* The navigation menu links */
.sidenav a {
float: right;
margin-right: 20px;
padding: 8px 8px 8px 8px;
text-decoration: none;
font-size: 15px;
color: #000000;
display: block;
transition: 0.3s;
margin-top: -40px;
}
/* When you mouse over the navigation links, change their color */
.sidenav a:hover {
color: #E26B00;
}
/* On smaller screens, where height is less than 450px, change the style of the sidenav (less padding and a smaller font size) */
@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}
/* Style the logo link (notice that we set the same value of line-height and font-size to prevent the header to increase when the font gets bigger */
#header a#title {
font-size: 130px;
font-weight: bold;
transition: 0.3s;
}
/* Style the active/current link*/
#header a.active {
background-color: dodgerblue;
color: white;
}
/* Float the link section to the right */
.navicon {
float: right;
}
/* Add media queries for responsiveness - when the screen is 500px wide or less, stack the links on top of each other */
@media screen and (max-width: 500px) {
#header a {
float: none;
display: block;
text-align: left;
}
.navicon {
float: none;
}
}
#container{
width: 100%;/* Your width */
height: 100%;/* Your height */
display: flex;
justify-content: center; /* This will center container with items horizontally */
align-items: center; /* This will center container with items vertically */
/* outline: 5px dashed yellow;
*/
}
#mySidenav{
width: 0px;
}
#mySidenav.open{
width: 500px;
}
<div id="header">
<a href="#default" id="title">Kunden;</a>
<div id="navplusicon">
<div class="navicon">
<div class="menu_bar_icon" onclick="myFunction(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
</div>
<div id="mySidenav" class="sidenav">
<a href="#">Home</a>
<a href="#">Über Mich</a>
<a href="#">Portfolio</a>
<a href="#">Kontakt</a>
</div>
</div>
</div>