Я пытаюсь разместить мое меню горизонтально на мобильной версии следующим образом:
![enter image description here](https://i.stack.imgur.com/7xZdd.png)
Но когда я изменил значения на:
. Левая сторона (белая): ширина: 100% высота: 40vh
и
.menu (правая сторона черная): ширина: 100%; высота: 60vh;
Но когда я это делаю, меню ломается. Правое меню вверху.
Я видел, что если я изменю высоту на 100% для навигации, это будет работать. Но потом, когда я go вернулся к настольной версии, при использовании инспектора элементов меню все время находилось вверху (слой) (я не могу выбрать текст). Я пробовал с z-index и ничего. Навигация, я думаю, должна быть высотой: 80px на рабочем столе и 100vh, но я не знаю.
CodePen здесь: https://codepen.io/ZeR0ByTe/pen/KKdzmJV?editors=0100
<nav id="navbar">
<div id="left-side" class="left-side">
<div class="profile">
<img class="picture" src="img/foto.jpg" alt="">
</div>
</div>
<div id="menu" class="menu">
<a href="#">Home</a>
<a href="#">Education</a>
<a href="#">Experience</a>
<a href="#">Languages</a>
<a href="#">Skills</a>
<a href="#">Portfolio</a>
<a href="#">References</a>
<a href="#">Contact me</a>
</div>
<div class="containerIconMobile">
<div id="toggle" class="iconMobile">
</div>
</div>
</nav>
<header>
<div class="overlay"></div>
<div class="header-content">
<div class="content">
<h1 class="main-title">Diego J. <span>Franchina</span></h1>
<h2 class="second-title">Web <span>Designer</span> / Web <span>Developer</span></h2>
</div>
<div class="social-icons">
<i class="social-icon fa fa-facebook-official fa-2x" aria-hidden="true"></i>
<i class="social-icon fa fa-instagram fa-2x" aria-hidden="true"></i>
<i class="social-icon fa fa-linkedin fa-2x" aria-hidden="true"></i>
<i class="social-icon fa fa-github fa-2x" aria-hidden="true"></i>
</div>
</div>
</header>
<main>
<div class="container">
<div class="title-section">
<h2>EDUCATION</h2>
<hr class="line-titles">
</div>
<div class="container-education">
<div class="education-schools">
<h3 class="item-school">Instituto Superior Argentino de Computación</h3>
<h4 class="item-title-school">Analista de Sistemas</h4>
<p class="item-description-school">Legalizado y Certificado en el Ministerio de Relaciones Exteriores para poder trabajar en el Exterior.</p>
<hr class="line-separator">
</div>
<div class="education-years">
<p class="item-description-school">2009 - 2012</p>
</div>
<hr class="line-separator">
</div>
<div class="container-education">
<div class="education-schools">
<h3 class="item-school">Nuestra Sra. del Buen y Perpetuo Socorro</h3>
<h4 class="item-title-school">Bachillerato</h4>
<p class="item-description-school">Perito Mercantil.</p>
<hr class="line-separator">
</div>
<div class="education-years">
2009 - 2012
</div>
</div>
</div>
<div class="container">
<div class="title-section">
<h2>EDUCATION</h2>
<hr class="line-titles">
</div>
<div class="container-education">
<div class="education-schools">
<h3 class="item-school">Instituto Superior Argentino de Computación</h3>
<h4 class="item-title-school">Analista de Sistemas</h4>
<p class="item-description-school">Legalizado y Certificado en el Ministerio de Relaciones Exteriores para poder trabajar en el Exterior.</p>
<hr class="line-separator">
</div>
<div class="education-years">
<p class="item-description-school">2009 - 2012</p>
</div>
<hr class="line-separator">
</div>
<div class="container-education">
<div class="education-schools">
<h3 class="item-school">Nuestra Sra. del Buen y Perpetuo Socorro</h3>
<h4 class="item-title-school">Bachillerato</h4>
<p class="item-description-school">Perito Mercantil.</p>
<hr class="line-separator">
</div>
<div class="education-years">
2009 - 2012
</div>
</div>
</div>
<div class="container">
<div class="title-section">
<h2>EDUCATION</h2>
<hr class="line-titles">
</div>
<div class="container-education">
<div class="education-schools">
<h3 class="item-school">Instituto Superior Argentino de Computación</h3>
<h4 class="item-title-school">Analista de Sistemas</h4>
<p class="item-description-school">Legalizado y Certificado en el Ministerio de Relaciones Exteriores para poder trabajar en el Exterior.</p>
<hr class="line-separator">
</div>
<div class="education-years">
<p class="item-description-school">2009 - 2012</p>
</div>
<hr class="line-separator">
</div>
<div class="container-education">
<div class="education-schools">
<h3 class="item-school">Nuestra Sra. del Buen y Perpetuo Socorro</h3>
<h4 class="item-title-school">Bachillerato</h4>
<p class="item-description-school">Perito Mercantil.</p>
<hr class="line-separator">
</div>
<div class="education-years">
2009 - 2012
</div>
</div>
</div>
</main>
CSS
$grey: #222222;
$secondTitle: #999999;
$pink: #fd5c63;
$white: #ffffff;
$black: #000000;
$primary-color: #ffc20e;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Lato", sans-serif;
}
html {
overflow-x: hidden;
}
span {
color: $primary-color;
font-weight: bolder;
}
body {
color: $white;
width: 100%;
background-color: $grey;
}
header {
width: 100%;
height: 100vh;
position: relative;
background: url(../img/wall2.jpg);
background-position: center;
background-size: cover;
.overlay {
background-color: rgba(0, 0, 0, 0.7);
width: 100%;
height: 100%;
position: absolute;
top: 0;
z-index: 0;
}
.header-content {
width: 40%;
height: 100vh;
position: absolute;
display: flex;
flex-direction: column;
justify-content: center;
padding: 50px;
text-align: center;
z-index: 1;
.main-title {
font-size: 54px;
font-weight: bold;
text-shadow: 4px 4px 2px rgba(0, 0, 0, 0.7);
}
.second-title {
text-shadow: 4px 4px 2px rgba(0, 0, 0, 0.7);
padding: 20px;
}
.social-icons {
display: flex;
justify-content: space-between;
padding: 10px;
.social-icon {
text-shadow: 4px 4px 2px rgba(0, 0, 0, 0.7);
padding: 10px;
transition: 1s ease;
&:hover {
color: $primary-color;
}
}
}
}
}
nav {
display: flex;
width: 100%;
height: 80px;
color: $black;
position: fixed;
top: 0;
z-index: 4;
.left-side {
width: 40%;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: rgba(119, 116, 116, 0.95);
position: absolute;
left: -100%;
transition: 1s ease;
z-index: 5;
&.left-effect {
left: 0 !important;
}
.profile {
.picture {
border-radius: 50%;
width: 200px;
height: 200px;
object-fit: cover;
border: 5px solid $primary-color;
}
}
}
.menu {
position: absolute;
right: -100%;
width: 60%;
height: 100vh;
background-color: rgba(0, 0, 0, 0.6);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
transition: 1s ease;
&.right-effect {
right: 0;
}
a {
display: flex;
flex-direction: column;
text-decoration: none;
color: #999999;
font-size: 24px;
font-weight: bolder;
letter-spacing: 5px;
padding: 10px 0;
transition: 1s;
text-transform: uppercase;
&:hover {
color: $primary-color;
}
}
}
.containerIconMobile {
position: absolute;
top: 30px;
right: 30px;
.iconMobile {
width: 30px;
height: 30px;
position: relative;
cursor: pointer;
&:before {
content: '';
position: absolute;
top: 7px;
width: 100%;
height: 2px;
background-color: $white;
transition: 1s ease;
}
&:after {
content: '';
position: absolute;
bottom: 7px;
width: 100%;
height: 2px;
background-color: $white;
transition: 1s ease;
}
&.active {
&:before {
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(45deg);
}
&:after {
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(-45deg);
}
}
}
}
}
main {
.container {
width: 98%;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
z-index: 4;
.title-section {
text-align: center;
font-size: 24px;
margin: 20px;
}
.line-titles {
border: 3px solid #ffc20e;
width: 25%;
margin: 10px auto;
}
}
.container-education {
width: 70%;
display: flex;
justify-content: center;
align-items: center;
}
.education-schools {
width: 70%;
margin-bottom: 30px;
.item-school {
font-size: 24px;
}
.item-title-school {
font-size: 22px;
color: #999999;
}
.item-description-school {
font-size: 20px;
margin: 10px 0;
}
.line-separator {
border: 3px solid #999999;
width: 25%;
margin: 30px auto 0 auto;
}
}
.education-years {
width: 30%;
font-size: 20px;
text-align: right;
}
}
@media (max-width: 480px) {
body {
header {
.header-content {
width: 100%;
.main-title {
font-size: 35px;
}
.second-title {
font-size: 18px;
}
}
}
nav {
.left-side {
top: 0;
background-color: rgba(119, 116, 116, .9);
z-index: 2;
.profile {
.picture {
width: 120px;
height: 120px;
}
}
}
.menu {
z-index: 2;
background-color: rgba(0, 0, 0, 0.9);
right: -100% !important;
// bottom: -825%;
&.right-effect {
right: 0 !important;
}
a {
font-size: 18px;
}
}
.containerIconMobile {
z-index: 4;
.iconMobile {
&:before {
background-color: $white;
}
&:after {
background-color: $white;
}
}
}
}
main {
.container-education {
width: 90%;
flex-direction: column;
}
}
}
}
JS
const toggle = document.getElementById("toggle");
const leftSide = document.getElementById("left-side");
const navbar = document.getElementById("navbar");
const menu = document.getElementById("menu");
toggle.addEventListener("click", () =>{
// navbar.classList.toggle("active")
toggle.classList.toggle("active");
leftSide.classList.toggle("left-effect");
menu.classList.toggle("right-effect");;
})
Надеюсь, кто-то может помочь и понять мой пост. Если нет, я постараюсь быть более точным c
Спасибо