html menu animation completely broken?


Nathan Pereira

I'm trying to teach myself front-end development through online resources like w3schools.com and Code Academy, and I have the most basic knowledge of HTML and CSS. I started a little portfolio web project to test myself and see what I didn't know. Also follow the menu icon animation tutorial on w3schools https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_menu_icon_jsI'm stuck when my code animation doesn't want to run. I copied and pasted the code from the tutorial into a new Visual Studio file and it worked without issue. I believe it has something to do with the fact that my Javascript code is in a different file and I linked it to the HTML code by mistake, but it still doesn't work when I move it around, so I'm totally lost on what might be the problem. Any help is greatly appreciated

HTML code:

    <!DOCTYPE html>
<html>
<head>
    <link href="main page.css" rel="stylesheet">
    <title>Cal's Blog</title>
</head>
<body>
        <div class="container" onclick="myFunction(this)">
            <div class="bar1"></div>
            <div class="bar2"></div>
            <div class="bar3"></div>
        </div>
    <script src="main page.js"></script>
</body>
CSS code:
    .container {
display: inline-block;
cursor: pointer;
}

.bar1, .bar2, .bar3 {
width: 35px;
height: 5px;
background-color: #333;
margin: 6px 0;
transition: 0.4s;
}

.change .bar1 {
-webkit-transform: rotate(-45deg) translate(-9px, 6px);
transform: rotate(-45deg) translate(-9px, 6px);
}

.change .bar2 {opacity: 0;}

.change .bar3 {
-webkit-transform: rotate(45deg) translate(-8px, -8px);
transform: rotate(45deg) translate(-8px, -8px);
}

JavaScript code:

    function myFunction(x) {x.classlist.toggle("change");}
Kapil Sharma

Your function must be:

function myFunction(x) {
        x.classList.toggle("change");
}

It's a classList with a capital "L" instead of "l".

Related


Start menu is broken and icons are completely missing

grim Reaper So this is my best title. This all started when I was playing skyrim and it crashed and I couldn't open the task manager so I logged out and logged in again. After that, I couldn't click anything related to Windows in the taskbar (sound manager, no

Start menu is broken and icons are completely missing

grim Reaper So this is my best title. This all started when I was playing skyrim and it crashed and I couldn't open the task manager so I logged out and logged in again. After that, I couldn't click anything related to Windows in the taskbar (sound manager, no

HTML website menu animation

Mike HTML: <div id="menu" class="menu"> <ul class="headlines"> <li id="item1"onclick="checklist(this)"><button onclick="myFunction()">AA</button></li> <li id="item2"><button onclick="myFunction2()">A </button></li> <

HTML website menu animation

Mike HTML: <div id="menu" class="menu"> <ul class="headlines"> <li id="item1"onclick="checklist(this)"><button onclick="myFunction()">AA</button></li> <li id="item2"><button onclick="myFunction2()">A </button></li> <

Website is completely broken in Safari

User 3453428 I noticed something very strange. My website ( http://wizztune.com ) looks perfectly fine in Chrome and Firefox, but is broken in Safari and some parts are missing. Also, Safari treats my "position: fixed" property as being ignored. Seems like a l

Ubuntu eclipse is completely broken

bug free For some time now I've had issues with 100% cpu on Eclipse startup. After creating a new workspace and switching to it, I noticed that the Android Dev Tools no longer show up anywhere. Actually, File-New-project only shows "General" and "CVS" projects

Website is completely broken in Safari

User 3453428 I noticed something very strange. My website ( http://wizztune.com ) looks perfectly fine in Chrome and Firefox, but is broken in Safari and some parts are missing. Also, Safari treats my "position: fixed" property as being ignored. Seems like a l

Ubuntu eclipse is completely broken

bug free For some time now I've had issues with 100% cpu on Eclipse startup. After creating a new workspace and switching to it, I noticed that the Android Dev Tools no longer show up anywhere. Actually, File-New-project only shows "General" and "CVS" projects

Ubuntu eclipse is completely broken

bug free For some time now I've had issues with 100% cpu on Eclipse startup. After creating a new workspace and switching to it, I noticed that the Android Dev Tools no longer show up anywhere. Actually, File-New-project only shows "General" and "CVS" projects

IntelliJ java autocomplete completely broken

Crab croaker So about 6 months ago, I stopped working on a Minecraft plugin I was working on with IntelliJ. Now, I finally re-gathered all my Java knowledge and am ready to code, but there is one problem. IntelliJ's autocompletion hardly works, only suggesting

The animation is not completely over

Jeffrey Rocha I have a text slide, but it completes before fully sliding, the element with the text is position: absolute, left: 100%. I applied an animation in it from left to 100% to -100%, expected all elements to move out from the right >> out on the left,

The animation is not completely over

Jeffrey Rocha I have a text slide, but it completes before fully sliding, the element with the text is position: absolute, left: 100%. I applied an animation in it from left to 100% to -100%, expected all elements to move out from the right >> out on the left,

Broken animation SwiftUI

Simi Buck I originally had this question here . The solution proposed by @arsenius works for this toy example. However, my app is more complicated and it took me all day to figure out where the animation breaks. In the example, I used two animations . However,

Animation on jQuery is broken

Icultlive Icultlive Please help me correct my script : http://jsfiddle.net/b36cM/ if(direction == -1){ wrapperElements.children(':last').after($('#carousel > ul').children().slice(0, options.rotateBy).clone());

Broken animation SwiftUI

Simi Buck I originally had this question here . The solution proposed by @arsenius works for this toy example. However, my app is more complicated and it took me all day to figure out where the animation breaks. In the example, I used two animations . However,

Broken animation SwiftUI

Simi Buck I originally had this question here . The solution proposed by @arsenius works for this toy example. However, my app is more complicated and it took me all day to figure out where the animation breaks. In the example, I used two animations . However,

Animation on jQuery is broken

Icultlive Icultlive Please help me correct my script : http://jsfiddle.net/b36cM/ if(direction == -1){ wrapperElements.children(':last').after($('#carousel > ul').children().slice(0, options.rotateBy).clone());

Broken animation SwiftUI

Simi Buck I originally had this question here . The solution proposed by @arsenius works for this toy example. However, my app is more complicated and it took me all day to figure out where the animation breaks. In the example, I used two animations . However,

Gnome menu broken?

Bentley Carr I think my "Application Menu" (top right corner of Gnome fallback) is broken. I was messing around with MenuLibre, and after closing it, an additional "System Tools" menu appeared above the attachment that contained only Synaptic "folders" (the me

offcanvas menu link is broken

Jensen 010 I'm working on a school project and I'm running into a problem and hope someone can help (and maybe curb my joomla hatred, but that's not the point :) First, here is the URL : http://edcc3.cloudaccess.net The problem is that the offcanvas menu link

Broken dropdown menu

username I've been trying to find a solution using a menu that is not showing up on a custom html site, but for some reason I can't find a solution and I'm curious what I'm doing wrong. <div class="header_area fix" id="header"> <div class="header_to

Now my menu is broken

Artsem Stalavitski After the last update, my unity menu didn't work properly. When the program window is below this menu, if you click any shortcut icon. Clicking seems to work on windows. Not on the launcher menu with shortcuts. You can see the menu, but clic

Gnome menu broken?

Bentley Carr I think my "Application Menu" (top right corner of Gnome fallback) is broken. I was messing around with MenuLibre, and after closing it, an additional "System Tools" menu appeared above the attachment that contained only Synaptic "folders" (the me

Broken dropdown menu

username I've been trying to find a solution using a menu that is not showing up on a custom html site, but for some reason I can't find a solution and I'm curious what I'm doing wrong. <div class="header_area fix" id="header"> <div class="header_to

Now my menu is broken

Artsem Stalavitski After the last update, my unity menu didn't work properly. When the program window is below this menu, if you click any shortcut icon. Clicking seems to work on windows. Not on the launcher menu with shortcuts. You can see the menu, but clic