Skip to content
Advertisement

Parent element changing when javascript applies a transformation

I am trying to create a side menu navigation that slides into and off of the screen when you click a button. I have a container around the menu and the button so that they move together. The width of the container is 13% along with the menu which is weird that the menu is 13% of the body and not of the container. However, when I click the button the menu width becomes 13% of the container and no longer of the body. I would like the width to stay the same but I cannot figure out why it is doing this.

Note I have multiple CSS sheets for each screen size that is why function screensize() is there.

JavaScript
JavaScript
JavaScript

Advertisement

Answer

I think you can get away with your javascript doing a single thing: adding and removing an open class.

Everything else you should be able to achieve with CSS.

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement