I made a menu, but when closed, it disappears in parts. First, all the items are stretched to the width of the window and go from top to bottom, then the background disappears, then the names, it happens quickly, but this one second looks very ugly. There are no animations in the code. This happens in both desktop and mobile versions.
.nav {
height: 100vh;
margin-left: calc(20% - 100px);
position: relative;
outline: none;
}
.nav ul {
list-style: none;
padding: 0.5em 0;
margin: 0;
}
.nav ul li {
margin: 10px;
height: 40px;
line-height: 40px;
background-color: white;
padding: 0.5em 1em 0.5em 1em;
font-size: 24px;
-webkit-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
transition: all 0.15s linear;
border-radius: 5px;
border: 1px solid black;
opacity: 0.75;
}
.nav li a {
display: block;
text-align: center;
padding-left: 0.5em;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
.menu {
display: -ms-grid;
display: grid;
grid-template-areas: "home home" "gallery ut" "journal contact";
-ms-grid-rows: 65px 10px 65px 10px 65px;
grid-template-rows: 65px 65px 65px;
-ms-grid-columns: 365px 10px 365px;
grid-template-columns: 365px 365px;
grid-gap: 10px;
height: 100vh;
position: relative;
z-index: 5;
}
.home .icon {
background: url(#) no-repeat;
background-size: contain;
}
.gallery .icon {
background: url(#) no-repeat;
background-size: contain;
}
.ut .icon {
background: url(#) no-repeat;
background-size: contain;
}
.journal .icon {
background: url(#) no-repeat;
background-size: contain;
}
.contact .icon {
background: url(#) no-repeat;
background-size: contain;
}
.icon {
margin-left: -0.25em;
}
.home {
-ms-grid-row: 1;
-ms-grid-column: 1;
-ms-grid-column-span: 3;
grid-area: home;
}
.gallery {
-ms-grid-row: 3;
-ms-grid-column: 1;
grid-area: gallery;
}
.ut {
-ms-grid-row: 3;
-ms-grid-column: 3;
grid-area: ut;
}
.journal {
-ms-grid-row: 5;
-ms-grid-column: 1;
grid-area: journal;
}
.contact {
-ms-grid-row: 5;
-ms-grid-column: 3;
grid-area: contact;
}
.menu li:hover {
background-color: #ffffff;
opacity: 1;
}
#menu-toggle {
width: 65px;
height: 65px;
display: -webkit-box;
display: flex;
-webkit-box-pack: center;
justify-content: center;
-webkit-box-align: center;
align-items: center;
border-radius: 50%;
cursor: pointer;
display: none;
}
#menu-toggle:hover .bar {
width: 25px;
}
#menu-toggle.closeMenu .bar {
width: 25px;
}
#menu-toggle.closeMenu .bar:first-child {
-webkit-transform: translateY(7px) rotate(45deg);
transform: translateY(7px) rotate(45deg);
}
#menu-toggle.closeMenu .bar:nth-child(2) {
-webkit-transform: scale(0);
transform: scale(0);
}
#menu-toggle.closeMenu .bar:last-child {
-webkit-transform: translateY(-7px) rotate(-45deg);
transform: translateY(-7px) rotate(-45deg);
}
.bar {
width: 25px;
height: 2px;
background: #fff;
-webkit-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.bar:nth-child(2) {
margin: 5px 0;
}
@media screen and (max-width: 1023px) {
.menu {
display: block;
background-image: url(#);
height: 100vh;
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 5;
visibility: hidden;
}
.menu.showMenu1 {
visibility: visible;
}
#menu-toggle {
display: -webkit-box;
display: flex;
position: relative;
z-index: 6;
}
.nav {
margin-left: 0;
}
ul.showMenu {
padding-top: 5em;
visibility: visible;
}
ul.showMenu li {
width: 300px;
margin: 0 auto;
}
ul.showMenu span {
text-align: right;
}
ul.showMenu li a {
background-color: white;
color: rgb(0, 0, 0);
opacity: 0.75;
}
}
<nav class="nav" role="navigation">
<div id="menu">
<div id="menu-toggle">
<div id="menu-icon">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</div>
</div>
<ul class="menu">
<li class="home"><a class="icon" href="#"><span>home</span></a></li>
<li class="gallery"><a class="icon" href="#"><span>gallery</span></a></li>
<li class="ut"><a class="icon" href="#"><span>ut</span></a></li>
<li class="journal"><a class="icon" href="#"><span>journal</span></a></li>
<li class="contact"><a class="icon" href="#"><span>contact</span></a></li>
</ul>
</div>
</nav>