1

I've made a lot of progress on my site, but the problem is that my burger menu doesn't show up, does anyone have an idea what's causing this please? I tried different things, debugging and so on but I can't make it appear again -_- So if anyone knows why, and has explanations I'm a taker I'm completely lost I know what to do lol

And then if you have other constructive criticism on my code of course I'm a taker thank you in advance for giving me your time

$('.m-nav-toggle').click(function(e) {
    e.preventDefault();
    $('.m-right').toggleClass('is-open');
    $('m-nav-toggle').toggleClass('is-open');
})
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,900;1,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@900&display=swap');

.menu {
    background: #757de8;
    width: 100%;
    height: 66px;
    line-height: 66px;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
}

.m-left {
    float: left;
}

.logo {
    margin: 0;
    padding: 0;
}

.m-right {
    float: right;
}

.m-links {
    text-decoration: none;
    color: #fff;
    text-transform: uppercase;
    font-weight: 700;
    padding: 0;
    margin: 0 15px;
    font-family: 'Lato', sans-serif;
    transition: all 0.3s ease-in-out;
    border-bottom: 2px solid transparent;
    padding-bottom: 3px;
}

.m-links:hover {
    border-color: #fff;
}

.m-links i {
    margin-right: 5px;
}

.m-nav-toggle {
    width: 40px;
    height: 66px;
    display: none;
    align-items: center;
    float: right;
    cursor: pointer;
}

span.m-nav-toggle-icon,
span.m-toggle-icon:before,
span.m-toggle-icon:after {
    content: "";
    display: block;
    width: 100%;
    height: 3px;
    background: #fff;
    position: relative;
    transition: all 0.3s ease-in-out;
}

span.m-toggle-icon:before {
    top: 12px;
}

span.m-toggle-icon:after {
    top: -14px;
}

.m-right.is-open {
    transform: translateX(0);
}

.m-nav-toggle.is-open span.m-toggle-icon {
    background: transparent;
}

.m-nav-toggle.is-open span.m-toggle-icon:before, .m-nav-toggle.is-open span.m-toggle-icon:after {
    transform-origin: center;
    transform: rotate(45deg);
    top: 0;
}

@media only screen and (max-width: 950px) {
    .m-right {
        position: absolute;
        top: 66px;
        right: 0;
        width: 200px;
        height: 100%;
        background: #757de8;
        transform: translateX(100%);
        transition: all 0.3s ease-in-out;
    }

    .m-links {
        display: block;
        text-align: center;
        padding: 0;
        margin: 0 20px;
        height: 55px;
    }

    .m-nav-toggle.is-open span.m-toggle-icon:before {
        transform: rotate(-45deg);
    }

    .m-nav-toggle {
        display: flex;
    }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"
        integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ=="
        crossorigin="anonymous" 
        referrerpolicy="no-referrer"
></script>

<script src="https://kit.fontawesome.com/8b1b202200.js" crossorigin="anonymous"></script>

<header role="header">
    <nav class="menu" role="navigation">
        <div class="inner">
            <img class="fit-picture" src="img/logo.svga">
            <div class="m-left"></div>

            <div class="m-right">
                <a href="" class="m-links"><i class="fas fa-home"></i> Home</a>
                <a href="" class="m-links"><i class="fas fa-book"></i> Documentation</a>
                <a href="" class="m-links"><i class="fas fa-comments"></i> Feedback</a>
                <a href="" class="m-links"><i class="fas fa-handshake"></i> Partners</a>
                <a href="" class="m-links"><i class="fas fa-envelope"></i> Contact</a>
            </div>
            
            <div class="m-nav-toggle">
                <span class="m-toggle-icon"></span>
            </div>
        </div>
    </nav>
</header>

File : normalize.css :

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

.inner {
  width: 80%;
  margin: auto;
}

enter code here
biberman
  • 5,606
  • 4
  • 11
  • 35
  • Sorry but I don't see the changes made –  Jul 22 '21 at 13:20
  • In your snippet no change has been made: There is still the problem on the second bar of the burger menu, and the different links (for some are not correctly displayed) –  Jul 23 '21 at 13:01

1 Answers1

0

The "m-toggle-icon" class needs "width:100%" and it will be shown. This is because its parent has "display: flex".

Working example:

$('.m-nav-toggle').click(function(e) {
    e.preventDefault();
    $('.m-right').toggleClass('is-open');
    $('m-nav-toggle').toggleClass('is-open');
})
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,900;1,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@900&display=swap');

.menu {
    background: #757de8;
    width: 100%;
    height: 66px;
    line-height: 66px;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
}

.m-left {
    float: left;
}

.logo {
    margin: 0;
    padding: 0;
}

.m-right {
    float: right;
}

.m-links {
    text-decoration: none;
    color: #fff;
    text-transform: uppercase;
    font-weight: 700;
    padding: 0;
    margin: 0 15px;
    font-family: 'Lato', sans-serif;
    transition: all 0.3s ease-in-out;
    border-bottom: 2px solid transparent;
    padding-bottom: 3px;
}

.m-links:hover {
    border-color: #fff;
}

.m-links i {
    margin-right: 5px;
}

.m-nav-toggle {
    width: 40px;
    height: 66px;
    display: none;
    align-items: center;
    float: right;
    cursor: pointer;
}

span.m-nav-toggle-icon,
span.m-toggle-icon:before,
span.m-toggle-icon:after {
    content: "";
    display: block;
    width: 100%;
    height: 3px;
    background: #fff;
    position: relative;
    transition: all 0.3s ease-in-out;
}

span.m-toggle-icon:before {
    top: 12px;
}

span.m-toggle-icon:after {
    top: -14px;
}

.m-right.is-open {
    transform: translateX(0);
}

.m-nav-toggle.is-open span.m-toggle-icon {
    background: transparent;
}

.m-nav-toggle.is-open span.m-toggle-icon:before, .m-nav-toggle.is-open span.m-toggle-icon:after {
    transform-origin: center;
    transform: rotate(45deg);
    top: 0;
}

@media only screen and (max-width: 950px) {
    .m-right {
        position: absolute;
        top: 66px;
        right: 0;
        width: 200px;
        height: 100%;
        background: #757de8;
        transform: translateX(100%);
        transition: all 0.3s ease-in-out;
    }

    .m-links {
        display: block;
        text-align: center;
        padding: 0;
        margin: 0 20px;
        height: 55px;
    }

    .m-nav-toggle.is-open span.m-toggle-icon:before {
        transform: rotate(-45deg);
    }

    .m-nav-toggle {
        display: flex;
    }
}

.m-toggle-icon { 
    width: 100%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"
        integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ=="
        crossorigin="anonymous" 
        referrerpolicy="no-referrer"
></script>

<script src="https://kit.fontawesome.com/8b1b202200.js" crossorigin="anonymous"></script>

<header role="header">
    <nav class="menu" role="navigation">
        <div class="inner">
            <img class="fit-picture" src="img/logo.svga">
            <div class="m-left"></div>

            <div class="m-right">
                <a href="" class="m-links"><i class="fas fa-home"></i> Home</a>
                <a href="" class="m-links"><i class="fas fa-book"></i> Documentation</a>
                <a href="" class="m-links"><i class="fas fa-comments"></i> Feedback</a>
                <a href="" class="m-links"><i class="fas fa-handshake"></i> Partners</a>
                <a href="" class="m-links"><i class="fas fa-envelope"></i> Contact</a>
            </div>
            
            <div class="m-nav-toggle">
                <span class="m-toggle-icon"></span>
            </div>
        </div>
    </nav>
</header>
biberman
  • 5,606
  • 4
  • 11
  • 35
szilagyi.sandor
  • 204
  • 1
  • 6
  • Do you mean that I create "m-toggle-icon" and I define it width: 100% or I define it in a place where it is already defined? –  Jul 22 '21 at 13:02
  • I just simply added this to the end of your css file: .m-toggle-icon { width: 100%; }. – szilagyi.sandor Jul 22 '21 at 13:06
  • It works perfectly, thank you! On the other hand I miss a bar and the display of the menu is a bit broken. Would you know where this problem comes from or not at all please ? I have dev without even seeing the menu, but having entered all the parameters that seemed right but apparently I worked badly x) https://i.imgur.com/PqHZm2R.png –  Jul 22 '21 at 13:09
  • Do you have an idea or not please? –  Jul 22 '21 at 19:00
  • In your snippet no change has been made: There is still the problem on the second bar of the burger menu, and the different links (for some are not correctly displayed) ² –  Jul 23 '21 at 13:01