What could be causing my hamburger icon to malfunction?

https://codepen.io/anon/pen/QNqgMo

Curious why the top line of the animation isn't moving. Any code wizards out there who can spot the mistake?

Appreciate it!

#hamburger-icon.active .line-1 {
transform: translateY(25px) translateX(0) rotate(45deg);
-webkit-transform: translateY(25px) translateX(0) rotate(45deg);
-moz-transform: translateY(25px) translateX(0) rotate(45deg);
}
#hamburger-icon.active .line-2 {
opacity: 0;
}
#hamburger-icon.active .line-3 {
transform: translateY(-10px) translateX(0) rotate(-45deg);
-webkit-transform: translateY(-10px) translateX(0) rotate(-45deg);
-moz-transform: translateY(-10px) translateX(0) rotate(-45deg);

Answer №1

Presenting your solution:

View the revised code

#hamburger-icon {
  position: absolute;
  top: 25px;
  left: 25px;
  height: 27px;
  width: 50px;
  cursor: pointer;
  display: block;
}

#hamburger-icon .line {
  position: absolute;
  display: block;
  background: #c8c8c8;
  width: 22px;
  height: 2px;
  left: 0;
  transition: all 0.4s;
  -webkit-transition: all 0.4s;
  -moz-transition: all 0.4s;
}

#hamburger-icon .line.line-1 {
  top: 0px;
}

#hamburger-icon .line.line-2 {
  top: 7px;
}

#hamburger-icon .line.line-3 {
  top: 14px;
}

#hamburger-icon.active .line-1 {
  transform: translateY(-10px) translateX(0) rotate(45deg);
  -webkit-transform: translateY(-10px) translateX(0) rotate(45deg);
  -moz-transform: translateY(-10px) translateX(0) rotate(45deg);
}
#hamburger-icon.active .line-2 {
  opacity: 0;
}
#hamburger-icon.active .line-3 {
  transform: translateY(-10px) translateX(0) rotate(-45deg);
  -webkit-transform: translateY(-10px) translateX(0) rotate(-45deg);
  -moz-transform: translateY(-10px) translateX(0) rotate(-45deg);
}

There was an extra bracket in your code causing it to malfunction

Answer №2

An extra bracket can be found after the code snippet below:

#hamburger-icon .line.line-3 {
    top: 14px;
}

To resolve the issue, simply remove the extra bracket and your code should function as intended.

#hamburger-icon {
  position: absolute;
  top: 25px;
  left: 25px;
  height: 27px;
  width: 50px;
  cursor: pointer;
  display: block;
}

#hamburger-icon .line {
  position: absolute;
  display: block;
  background: #c8c8c8;
  width: 22px;
  height: 2px;
  left: 0;
  transition: all 0.4s;
  -webkit-transition: all 0.4s;
  -moz-transition: all 0.4s;
}

#hamburger-icon .line.line-1 {
  top: 0px;
}

#hamburger-icon .line.line-2 {
  top: 7px;
}

#hamburger-icon .line.line-3 {
  top: 14px;
}

#hamburger-icon.active .line-1 {
  transform: translateY(25px) translateX(0) rotate(45deg);
  -webkit-transform: translateY(25px) translateX(0) rotate(45deg);
  -moz-transform: translateY(25px) translateX(0) rotate(45deg);
}

#hamburger-icon.active .line-2 {
  opacity: 0;
}

#hamburger-icon.active .line-3 {
  transform: translateY(-10px) translateX(0) rotate(-45deg);
  -webkit-transform: translateY(-10px) translateX(0) rotate(-45deg);
  -moz-transform: translateY(-10px) translateX(0) rotate(-45deg);
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

HTML/JavaScript: Embrace the Power of Dynamic Page

I have a unique element in my HTML code: <image src="http://..." style='...'> Using Python-Flask, I pass on a dynamic source address and save it as window.dynamicEmbedding. Now, during page load, I want to change the image's ...

CSS must be applied to various sections of an HTML document

For example, I have 2 CSS files. In one CSS file, I have the style: a{color: blue;} In the second file, I have: a{color: red;} I want to apply these styles to my HTML file. <div> <a>first file ...

What is the best way to retrieve the border-color inline style using jQuery?

I have a HTML tag like this. <span id="createOrderFormId:accountNo" style="border-color: red;"><</span> To retrieve the style value for the border-color property, I tried using the following jQuery code: $( document ).ready(function() { ...

Next.js: Generating static sites only at runtime due to getStaticProps having no data during the build phase, skipping build time generation

I am looking to customize the application for individual customers, with a separate database for each customer (potentially on-premise). This means that I do not have access to any data during the build phase, such as in a CI/CD process, which I could use ...

Transfer file content by dragging and dropping it onto a TextArea when an anchor tag is dropped

Within my application, there are 2 textareas with corresponding code implementing "dragover" and "drop" listeners for each one: // for dragover handleDragOver : function (evt) { var self = this; evt.preventDefault(); console.log ( ...

jQuery does not change the scroll position of elements

I'm looking to implement a feature on my website where certain points act as "magnets" and when the user is near one of these points, the window automatically scrolls to the top. I found a jQuery plugin that does something similar which you can check ...

Is it recommended to utilize a "default" key within an object?

Creating a JavaScript application and looking to establish a config object. Here's what I have so far: var config = { localization: { locales: ['en', ..., 'de'], defaultLocale: 'en' } } Consideri ...

Fixing inconsistent font sizes across various browsers

During the development of my website, I couldn't help but notice a significant variance in font sizes between Internet Explorer and other browsers. Here's an example of what my page looks like: I intended for it to resemble the first and second ...

Issues with functionality of React/NextJS audio player buttons arise following implementation of a state

I am currently customizing an Audio Player component in a NextJs application using the ReactAudioPlayer package. However, the standard Import Next/Audio and using just <Audio> without props did not yield the expected results. The player functions as ...

Encoding a multidimensional associative array into JSON using PHP

Having used php's json_encode() function frequently in the past, I am puzzled by the current issue... Note: Error checking has been omitted for clarity. //PHP <?php session_start(); require 'global/query.php'; $sql = "SELECT sfl,statio ...

How to message someone privately in a public Discord channel using discord.js

Can someone help me figure out how to create a message in discord.js version 12.5.3 that only I can see? I know how to send messages to channels using message.channel.send, but I'm not sure how to make a message visible only to myself. Thank you! ...

Display a div when hovering over an image using jQuery

I've spent a good 30 minutes searching on Stack Overflow for a solution, but I haven't been able to find it yet. It's possible that I'm not sure what exactly to look for. Essentially, I have a div that contains an image and some text. ...

Error message: Injector Error: R3InjectorError(Standalone[_AppComponent])[_WebService -> _WebService -> _WebService] occurred

Being a student, I must apologize in advance for any mistakes in terminology or gaps in my understanding. I am currently developing an Angular front-end to communicate with my backend API. However, I keep encountering the following error in the web page c ...

difficulty in making an https request

My application was developed using OFFICEjs and was functioning properly on LOCALHOST. However, last week it suddenly started throwing an error message - "XHR Error." This issue arose out of nowhere, as I hadn't made any changes to the code over the w ...

Using a MySQL statement within a conditional statement

Looking to modify this code to display different information based on the values retrieved, here is the current code: $sql_doublecheck = mysql_query("SELECT * FROM adminpage WHERE setting='main' AND close_site='1'"); $doublecheck = mys ...

What is the best way to connect data so that when a user clicks on a specific card, it appears on a popup card

When a user clicks on any card containing data retrieved from a backend API GET method, that data should be displayed in a pop-up card. In my situation, I have two components: DisplayNotes.vue and UpdateNotes.vue. Whenever a user clicks on a displayed card ...

Angular Reactive Forms may not properly update other inputs when binding a control to multiple inputs

While working with reactive forms, I encountered an issue where accessing the same control in multiple inputs seemed to result in one-way data binding (input-to-model). If I make edits in one input, it updates the model correctly but does not refresh the o ...

Error in Typescript: 'SyncClient' not found in Twilio

While working on my Ionic app, I encountered an issue every time I attempted to use the twilio-chat library in my project through npm install. The error consistently appeared in the .d.ts files. Here is how I imported it in my provider : import { Client ...

Establishing Accessor and Mutator Methods

The variables startStopA... and InitialValueA... that were originally in the component TableFields.vue need to be relocated to the store file index.js. However, upon moving them to the store, an error appears stating that setters are not set. I have extens ...

Replace !important with JavaScript/jQuery when using animate()

I need to animate the background-position-x, but there is a background-position: 0 0 !important; set in the css that cannot be removed. Is it possible to work around this using JavaScript? My jQuery code is functioning as intended, but it is being overridd ...