Why isn't my animation running smoothly?

Hey friends, I’m making an animation for a hamburger style menu for my website. The ham-menu only appears through my media query when the screen is 425px or smaller. I’m using a little java Script and css animations to make the menu morph into an ‘X’ when clicked. I notice however that the transition jumps halfway through. Any ideas?

p.s-- Does the ‘X’ look straight? looks a little warped to me

It’s a bit fast to see, but the only part that looks jumpy to me is the middle bar fading out. Maybe rotating that too would look better.

I guess the jumpy effect could come from a number of things, but it’s all going to be down to the eye of the beholder as to what they perceive as “jumpy”. I think I’d try different fade durations on that middle bar to see whether that make any difference to how you’re seeing it.

There’s no need for keyframes here and you shouldn’t be repeating properties that don;t change. It probably makes no difference to performance but then again it just might :slight_smile:

Don’t move things using position and that is known to be jumpy but much more performant to use transforms to move elements instead.

Also I don’t understand why you are writing three inline styles into each bar of the hamburger when you could simply toggle a class and remove all the work to the css?

Putting all the above together you could remove the keyframes altogether and do this:

.m1, .m2, .m3 {
		border-radius: 4px;
		margin: 4px;
		width: 35px;
		height: 3px;
		background-color: red;
		float: left;
		position: relative;
		transition:all .3s ease;
		opacity:1;
}
.hamburger-open .m1{transform: rotate(45deg) translate(4px, 12px);}
.hamburger-open .m2{opacity:0}
.hamburger-open .m3{transform: rotate(-45deg) translate(3px, -12px);}

Then in the js just toggle the class which will allow the menu to open and then close when toggled.

<script>
const nav = document.querySelector('.ham-menu');
nav.addEventListener('click', animateMenu);
function animateMenu() {
	nav.classList.toggle('hamburger-open');
}
</script>

I notice you have 2 class attributes on this element!

<div class="inner" class="wrap">

If you need 2 classes then they should be space separated like so:

<div class="inner wrap">

Yes I think that’s because the end of the straight line is anti-aliased a little but when you transform it you have different ends aligning and thus semi transparent pixels at one end. In my code above I offset it by 1px which makes it look better. I would consider removing the border-radius also as that may make it cleaner.

This is what it looks like when I make the adjustments locally.

Note that running things in jsfiddle is always going to be slower than in real life so test outside jsfiddle as much as possible.

Just in case I missed something this is the whole code I tested.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kane Concrete & Construction LLC</title>
<link rel="stylesheet" href="../css/style.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Arvo|Bitter|Lato|Montserrat|Noto+Sans|Open+Sans|Poppins|Roboto|Sarabun|Ubuntu" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Abel|Asap|Krub|Oxygen|Rajdhani|Staatliches|Varela+Round" rel="stylesheet">
<style>
body, html {
	margin: 0;
	padding: 0;
}
/*---HEADER---*/

li a {
	text-decoration-line: none;
	color: rgba(102,102,102,0.75);
}
header {
	background: red;
	height: 100vh;
	background-attachment: fixed;
	background-repeat: no-repeat;
	display: flex;
	justify-content: center;
	align-items: center;
}
nav {
	background-color: white;
	width: 100%;
	display: flex;
	justify-content: space-between;
	align-items: center;
	position: fixed;
	top: 0;
	left: 0;
	z-index: 2;
	box-shadow: 0px 0px 100px grey;
}
ul {
	margin-right: 30px;
	margin-top: 25px;
}
li {
	display: inline-block;
	font-size: 1.55rem;
	margin-right: 20px;
	font-family: 'Rajdhani';
}
li a:hover {
	cursor: pointer;
	color: #1a1a1a;
	transition: all 0.7s ease;
}
.after:after {
	position: relative;
	left: 12px;
	top: 2px;
	display: inline-block;
	content: "";
	width: 1px;
	height: 20px;
	background-color: rgba(102,102,102,0.25);
}
.logo {
	color: red;
	font-size: 3.7rem;
	margin: 10px;
	opacity: 1;
	margin-left: 30px;
}
.phrase {
	text-align: center;
}
.phrase p {
	color: white;
	font-size: 3.5rem;
	font-family: 'Arvo';
	margin-bottom: 30px;
}
.phrase a {
	background-color: red;
	border-radius: 25px;
	color: white;
	font-family: 'Bitter';
	font-size: 1.8rem;
	padding-left: 15px;
	padding-right: 15px;
	padding-bottom: 10px;
	padding-top: 10px;
	transition: all 0.2s ease;
}
.phrase a:hover {
	transition: all 0.5s ease;
	background-color: #cc0000;
	cursor: pointer;
}
.phrase .fas {
	display: block;
	color: white;
	font-size: 3.5rem;
	margin-top: 15px;
}
/*---PROMISE---*/

.stats {
	width: 100%;
	display: flex;
	box-shadow: 0px 0px 150px grey;
	position: relative;
	z-index: 1;
	background-color: white;
}
.stats div {
	display: inline-block;
	flex-basis: 35%;
	text-align: center;
	padding-bottom: 30px;
}
.stat-info {
	font-size: 2rem;
	color: rgba(102,102,102, 1);
	font-family: 'Rajdhani';
	margin-bottom: 0;
	margin-top: 10px;
}
.stat-num {
	color: red;
	font-family: 'Rajdhani';
	font-size: 3rem;
	margin: 0;
	font-weight: bolder;
}
.stats div:before {
	display: inline-block;
	content: '';
	width: 2px;
	height: 35px;
	background-color: rgba(102,102,102, 0.60);
}
.promise {
	width: 100%;
	background: red;
	background-position: center;
	background-attachment: fixed;
	background-size: cover;
}
.promise .wrapper {
	width: 100%;
	background-color: rgba(0, 0, 0, 0.3);
}
.promise h1 {
	position: relative;
	top: 40px;
	color: white;
	font-family: 'Arvo';
	font-size: 3.5rem;
	text-align: center;
	margin-top: 0;
	word-spacing: 7px;
	text-shadow: 0px 0px 100px grey;
}
.promise p {
	color: white;
	font-size: 1.8rem;
	font-family: 'Rajdhani';
	margin-bottom: 0;
	padding-bottom: 60px;
	text-align: center;
	margin-top: 40px;
	padding-left: 50px;
	padding-right: 50px;
}
/*---FOOTER---*/

.footer .wrapper {
	display: flex;
}
.footer div {
	display: inline-block;
	flex-basis: 33.33%;
	font-family: 'Rajdhani';
	color: rgba(102,102,102, 1);
	margin-top: 5px;
}
.footer h1 {
	font-size: 2rem;
	margin-top: 15px;
}
.footer .inner {
	margin-left: 55px;
}
.social .inner {
	margin-left: 45px;
}
.contact .inner {
	margin-left: 35px;
}
.footer .inner:before {
	display: inline-block;
	content: '';
	width: 27.1%;
	height: 2px;
	background-color: rgba(102,102,102, 0.6);
	position: absolute;
	margin-top: 54px;
}
.footer h1 span {
	display: inline;
	position: relative;
}
.footer h1 span:after {
	content: '';
	height: 2px;
	width: 100%;
	background-color: red;
	position: absolute;
	bottom: 0;
	left: 0;
}
.wrap:before {
	content: '';
	width: 100px;
	height: 2px;
	background-color: red;
	position: absolute;
	margin-top: 55px;
}
.links a {
	display: block;
	text-decoration-line: none;
	color: rgba(102,102,102, 1);
	font-size: 1.2rem;
	position: relative;
	top: -10px;
	transition: color 0.4s ease;
}
.links a:hover {
	color: red;
}
.contact p {
	position: relative;
	top: -10px;
}
.social i {
	font-size: 1.7rem;
	margin-right: 5px;
	position: relative;
	top: -20px;
	color: rgba(102,102,102, 0.7);
	transition: all 0.4s ease;
}
.social i:hover {
	color: red;
	cursor: pointer;
}
#msg {
	margin-top: -15px;
}
.footer-textarea {
	background-color: rgba(102,102,102, 0.2);
	outline: none;
	color: rgba(102,102,102, 1);
	resize: none;
	width: 89%;
}
.footer button {
	float: right;
	margin-right: 9.5%;
	margin-top: -17px;
	border: none;
	font-family: 'Rajdhani';
	font-size: 1.2rem;
	transition: all ease 0.4s;
	outline: none;
}
button:hover {
	cursor: pointer;
	color: red;
}
.dark {
	color: red;
}
.copyright {
	position: absolute;
	background-color: white;
	text-align: center;
	width: 100%;
	margin-bottom: 0;
	font-size: 1.2rem;
	padding-bottom: 4px;
}



/*-------MEDIA QUERIES-------*/



/*---LAPTOP-LARGE---*/

@media screen and (min-width: 1440px) {
/*---FOOTER---*/

	.footer button {
	margin-left: 16.5%;
}
}

/*---LAPTOP---*/

@media screen and (max-width: 1024px) {
/*---NAV---*/

	.logo {
	font-size: 5rem;
}
nav li {
	font-size: 2.5rem;
}
/*---MAIN---*/

	header {
	height: 100vh;
}
/*---FOOTER---*/
	
	.footer .inner {
	margin-left: 30px;
}
.footer-textarea {
	width: 88%;
}
.footer button {
	margin-right: 10.25%;
}
.footer h1 span {
	display: inline;
	position: relative;
}
.footer h1 span:after {
	content: '';
	height: 2px;
	width: 100%;
	background-color: red;
	position: absolute;
	bottom: 0;
	left: 0;
}
}
 @media screen and (max-width: 1024px), screen and (max-height: 1366px) {
header {
	height: 80vh;
}
}
 @media screen and (max-width: 823px) {
/*---MAIN---*/

	.phrase p {
	font-size: 3rem;
}
}

/*------LANDSCAPE-MODE------*/

@media screen and (max-width: 812px) {
/*---NAV---*/

	nav li {
	font-size: 1.7rem;
}
.logo {
	font-size: 2.7rem;
}
/*---MAIN---*/

	header {
	height: 100vh;
}
.stats p {
	font-size: 2rem;
}
.promise p {
	font-size: 1.3rem;
}
/*---FOOTER---*/

	.footer button {
	margin-left: 8.5%;
}
.contact .inner {
	margin-right: 20px;
}
}

/*---TABLET---*/

@media screen and (max-width: 768px) {
/*---NAV---*/

	nav li {
	font-size: 1.6rem;
}
.logo {
	font-size: 3rem;
}
/*---MAIN---*/

	.phrase {
	top: 300px;
}
/*---FOOTER---*/

	.footer h1 span {
	display: inline;
	position: relative;
}
.footer h1 span:after {
	content: '';
	height: 2px;
	width: 100%;
	background-color: red;
	position: absolute;
	bottom: 0;
	left: 0;
}
.footer button {
	margin-left: 7.4%;
}
}
 @media screen and (max-width: 731px) {
/*---FOOTER---*/

	.footer button {
	margin-left: 6%;
}
.contact .inner p {
	margin: 5px;
}
}

/*------LANDSCAPE-MODE-MOBILE------*/

@media screen and (max-width: 715px) {
/*---NAV---*/

	.phrase {
	margin-top: 30px;
}
.phrase p {
	font-size: 2.5rem;
}
.phrase a {
	font-size: 1.5rem;
}
nav ul {
	padding-left: 0;
	margin: 0;
}
nav li {
	font-size: 1.4rem;
}
nav .logo {
	font-size: 2.5rem;
}
/*---FOOTER---*/

	.links a {
	font-size: 1.1rem;
	top: -13px;
}
.contact .inner {
	margin-right: 15px;
}
.contact p {
	margin: 5px;
}
.footer-textarea {
	position: relative;
	top: -5px;
	width: 90.5%;
}
.footer button {
	margin-top: -18px;
	margin-right: 7%;
	font-size: 1.1rem;
}
}
 @media screen and (max-width: 586px) {
/*---MAIN---*/

	.phrase p {
	font-size: 2.7rem;
}
.stats p {
	font-size: 1.5rem;
}
/*---FOOTER---*/

	.footer .wrapper {
	display: flex;
	flex-direction: column;
}
.footer div {
	margin: 0;
}
.footer h1 {
	font-size: 2rem;
	margin-top: 10px;
}
.footer .inner {
	margin: 0;
}
.footer .inner:before {
	display: inline-block;
	content: '';
	width: 100vw;
	height: 2px;
	background-color: rgba(102,102,102, 0.6);
	position: absolute;
	margin-top: 48px;
}
.footer h1 span:after {
	content: '';
	height: 2px;
	width: 100%;
	background-color: red;
	position: absolute;
	bottom: 1px;
	left: 0;
}
.social .inner {
	position: relative;
	top: -10px;
}
.links a {
	margin-left: 5px;
}
.social h1 {
	margin-bottom: 10px;
}
#msg {
	font-size: 1rem;
	margin-bottom: 0;
	margin-right: 25.5%;
	position: absolute;
	right: 5px;
	top: 80px;
}
.footer button {
	right: 9.25%;
	margin-top: 0.2px;
}
.social i {
	font-size: 1.8rem;
	margin-right: 2px;
	position: relative;
	top: -5px;
	left: 5px;
	color: rgba(102,102,102, 0.7);
	transition: all 0.4s ease;
}
.footer-textarea {
	width: 88.5%;
	margin-top: 25px;
	margin-left: 5px;
}
.contact p {
	margin: 5px;
	font-size: 1.2rem;
}
.copyright {
	background-color: red;
	padding-top: 10px;
	padding-bottom: 10px;
}
.copyright span {
	color: white;
	background-color: red;
}
}
 @media screen and (max-width: 568px) {
/*---MAIN---*/

	.phrase p {
	font-size: 2rem;
}
.phrase a {
	font-size: 1.3rem;
}
.stats p {
	font-size: 1.5rem;
}
.promise p {
	font-size: 1.3rem;
}
/*---FOOTER---*/

	.footer .wrapper {
	display: flex;
	flex-direction: column;
}
.footer div {
	margin: 0;
}
.footer h1 {
	font-size: 2rem;
	margin-top: 10px;
}
.footer .inner {
	margin: 0;
}
.footer .inner:before {
	display: inline-block;
	content: '';
	width: 100%;
	height: 2px;
	background-color: rgba(102,102,102, 0.6);
	position: absolute;
	margin-top: 48px;
}
.footer h1 span:after {
	content: '';
	height: 2px;
	width: 100%;
	background-color: red;
	position: absolute;
	bottom: 1px;
	left: 0;
}
.social .inner {
	position: relative;
	top: -10px;
}
.social .inner:before {
	width: 100vw;
}
.links a {
	margin-left: 5px;
}
.social h1 {
	margin-bottom: 10px;
}
#msg {
	font-size: 1rem;
	margin-bottom: 0;
	margin-right: 25.5%;
	position: absolute;
	right: 5px;
	top: 80px;
}
.footer button {
	right: 9.25%;
	margin-top: 0.2px;
}
.social i {
	font-size: 1.8rem;
	margin-right: 2px;
	position: relative;
	top: -5px;
	left: 5px;
	color: rgba(102,102,102, 0.7);
	transition: all 0.4s ease;
}
.footer-textarea {
	width: 88.5%;
	margin-top: 30px;
	margin-left: 5px;
}
.contact p {
	margin: 5px;
	font-size: 1.2rem;
}
.copyright {
	background-color: red;
}
.copyright span {
	color: white;
	background-color: red;
}
}
 @media screen and (max-width: 517px) {
/*---NAV---*/

	nav li {
	font-size: 1.1rem;
}
/*---MAIN---*/

	header h1 {
	font-size: 3rem;
}
/*---FOOTER---*/

	.footer .wrapper {
	display: flex;
	flex-direction: column;
}
.footer div {
	margin: 0;
}
.footer h1 {
	font-size: 2rem;
	margin-top: 10px;
}
.footer .inner {
	margin: 0;
}
.footer .inner:before {
	display: inline-block;
	content: '';
	width: 100vw;
	height: 2px;
	background-color: rgba(102,102,102, 0.6);
	position: absolute;
	margin-top: 48px;
}
.social .inner {
	position: relative;
	top: -10px;
}
.footer h1 span:after {
	content: '';
	height: 2px;
	width: 100%;
	background-color: red;
	position: absolute;
	bottom: 1px;
	left: 0;
}
.links a {
	margin-left: 5px;
}
.social h1 {
	margin-bottom: 10px;
}
#msg {
	font-size: 1.3rem;
	margin-bottom: 0;
	float: right;
	margin-right: 25.5%;
	position: relative;
	top: 15px;
}
.footer button {
	right: 9.25%;
	margin-top: 0.2px;
}
.social i {
	font-size: 1.8rem;
	margin-right: 7px;
	position: relative;
	top: -5px;
	left: 5px;
	color: rgba(102,102,102, 0.7);
	transition: all 0.4s ease;
}
.footer-textarea {
	width: 88.5%;
	margin-left: 5px;
	margin-top: 0px;
	position: relative;
	top: 10px;
}
.contact p {
	margin: 5px;
	font-size: 1.2rem;
}
.copyright {
	background-color: red;
}
.copyright span {
	color: white;
	background-color: red;
}
}

/*---MOBILE---*/

@media screen and (max-width: 425px) {
/*---NAV---*/

	.logo {
	font-size: 2.5rem;
	margin-left: 10px;
}
ul {
	margin: 0;
	padding: 0;
}
nav li {
	display: none;
}
.ham-menu {
	width: 55px;
	height: 55px;
	position: fixed;
	right: 0;
	top: 4px;
	display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;
}
.m1, .m2, .m3 {
	border-radius: 4px;
	margin: 4px;
	width: 35px;
	height: 3px;
	background-color: red;
	float: left;
	position: relative;
	transition:all .3s ease;
	opacity:1;
}
.hamburger-open .m1 {
	transform: rotate(45deg) translate(4px, 12px);
}
.hamburger-open .m2 {
	opacity:0
}
.hamburger-open .m3 {
	transform: rotate(-45deg) translate(3px, -12px);
}
/*---MAIN---*/

	.phrase {
	top: 179px;
}
.phrase p {
	font-size: 2.5rem;
	margin-bottom: 10px;
}
.phrase a {
	font-size: 1.3rem;
	padding: 7px;
}
.phrase .fas {
	margin-top: 10px;
	font-size: 2.5rem;
}
.stats p {
	font-size: 1.3rem;
}
.stats div {
	padding-bottom: 10px;
}
.stats div:before {
	height: 20px;
}
.promise h1 {
	font-size: 2.7rem;
}
.promise p {
	position: relative;
	top: 10px;
	font-size: 1.3rem;
}
/*---FOOTER---*/

	.footer .wrapper {
	display: flex;
	flex-direction: column;
}
.footer div {
	margin: 0;
}
.footer h1 {
	font-size: 2rem;
	margin-top: 10px;
}
.footer .inner {
	margin: 0;
}
.footer .inner:before {
	display: inline-block;
	content: '';
	width: 100vw;
	height: 2px;
	background-color: rgba(102,102,102, 0.6);
	position: absolute;
	margin-top: 48px;
}
.social .inner {
	position: relative;
	top: -9.5px;
}
.footer h1 span {
	display: inline;
	position: relative;
}
.footer h1 span:after {
	content: '';
	height: 2px;
	width: 100%;
	background-color: red;
	position: absolute;
	bottom: 1px;
	left: 0;
}
.links a {
	margin-left: 5px;
}
.social h1 {
	margin-bottom: 10px;
}
#msg {
	font-size: 1rem;
	margin-bottom: 0;
	margin-right: 25.5%;
	position: absolute;
	right: 5px;
	top: 80px;
}
.footer button {
	right: 9.25%;
	margin-top: 0.2px;
}
.social i {
	font-size: 1.8rem;
	margin-right: 2px;
	position: relative;
	top: -5px;
	left: 5px;
	color: rgba(102,102,102, 0.7);
	transition: all 0.4s ease;
}
.footer-textarea {
	width: 88.5%;
	margin-top: 0px;
	margin-left: 5px;
}
.contact p {
	margin: 5px;
	font-size: 1.2rem;
}
.copyright {
	background-color: red;
}
.copyright span {
	color: white;
	background-color: red;
}
}
 @media screen and (max-width: 360px) {
.footer button {
	margin-right: 8.5%;
}
}
</style>
</head>
<body>
<div class="inner-wrap">
  <header>
    <nav>
      <div class="logo"> <i class="fab fa-accusoft"></i> </div>
      <div class="nav">
        <div class="ham-menu">
          <div class="m1" id="m1"></div>
          <div class="m2" id="m2"></div>
          <div class="m3" id="m3"></div>
        </div>
        <ul>
          <li class="after"><a href="index.html">Home</a></li>
          <li class="after"><a href="about.html">About</a></li>
          <li class="after"><a href="about.html#services">Services</a></li>
          <li class="after"><a href="careers.html">Careers</a></li>
          <li><a href="contact.html">Contact</a></li>
        </ul>
      </div>
    </nav>
    <div class="phrase">
      <p>It all starts at the foundation.</p>
      <a>Get a Quote</a> <i class="fas fa-angle-down"></i> </div>
  </header>
  <section class="stats">
    <div id="start-year">
      <p class="stat-info">Established</p>
      <br>
      <p class="stat-num">2015</p>
    </div>
    <div id="projects">
      <p class="stat-info">Projects</p>
      <br>
      <p class="stat-num">200+</p>
    </div>
    <div id="claims">
      <p class="stat-info">Insurance claims</p>
      <br>
      <p class="stat-num">87%</p>
    </div>
  </section>
  <section class="promise">
    <div class="wrapper">
      <h1>Our Promise</h1>
      <p><span style="color: red;">W</span>e believe that Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum doloremque impedit laudantium magnam eos quae ipsum, rem, dolorum saepe laboriosam ipsam nobis architecto debitis, vel aut provident tenetur perferendis, aliquid commodi magni sequi hic quia nemo! Nam odio fugiat, similique eum saepe. Laboriosam officiis delectus reiciendis, est tenetur voluptates ducimus! Ducimus enim dolor, eos id porro, amet culpa alias sunt reprehenderit necessitatibus deserunt eum. Sunt quia accusamus facilis quo, cum maiores nam illum sit quisquam, tempora fugit? Quod voluptate debitis voluptatum illo. Est, rerum sequi. Corporis atque incidunt placeat aliquam error veniam quis, minus voluptatem, qui, a pariatur voluptatibus, ut. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe labore aliquid magnam velit, nisi consequuntur!</p>
    </div>
  </section>
</div>
<section class="footer">
  <div class="wrapper">
    <div class="links">
      <div class="inner">
        <h1><span>Quick Links</span></h1>
        <a href="index.html">Home</a> <a href="about.html">About</a> <a href="about.html#services">Services</a> <a href="careers.html">Careers</a> <a href="contact.html">Contact</a> <a href="contact.html#quote">Quote</a> </div>
    </div>
    <div class="social">
      <div class="inner">
        <h1><span>Social</span></h1>
        <i class="fab fa-linkedin"><a href="#" class="social-net"></a></i> <i class="fab fa-facebook"><a href="#" class="social-net"></a></i> <i class="fab fa-twitter-square"><a href="#" class="social-net"></a></i>
        <button name="msg">Send</button>
        <textarea name="msg" class="footer-textarea" cols="46" rows="5" placeholder="Send is some feedback..."></textarea>
      </div>
    </div>
    <div class="contact">
      <div class="inner wrap">
        <h1><span>Contact</span></h1>
        <p>(208)546-7827 - <span class="dark">Matt</span></p>
        <p>(208)546-7827 - <span class="dark">Keegan</span></p>
        <p><span class="dark">Address</span> - P.O. Box 50860 IF, ID 83405</p>
        <p><span class="dark">Email</span> - KaneConcrete@fake.com</p>
      </div>
    </div>
  </div>
  <div class="copyright"><span>&copy; 2019 - Kane Concrete & Construction | ALL RIGHTS RESERVED</span></div>
</section>
<script>
const nav = document.querySelector('.ham-menu');
nav.addEventListener('click', animateMenu);
function animateMenu() {
	nav.classList.toggle('hamburger-open');
}
</script>
</body>
</html>

@PaulOB Dude you are incrdible. Always responding to my questions and going above and beyond in detail and suggestions. I really can’t stress enough how much you have helped me, I just love you man your making a difference:) On a side note I’ve never seen two classes connected like that(.hamburger-open .m1{transform: rotate(45deg) translate(4px, 12px);}) What is this?

2 Likes

Do you mean the rotate and translate values for the transform?

If so they are just space separated values for the transform property. You can’t have them in separate rules as one would overide the other ( much like using background:red would override any image set previously for that element.

I don’t think you meant the descendant selector (.hamburger-open .m1 {}) as you are using many similar rules in your code :slight_smile:

Your right I do use that, this instance confuses me though because the .hamburger-open class isn’t declared in my HTML. I’m guessing the nav.classList.toggle(‘hamburger-open’); in the JS adds the class to the nav? Also will the click event work with a finger touch on mobile?

Yes the js just toggles a class and then css can do all the heavy lifting. You should generally try and avoid js changing the style directly as it writes an inline style which trumps the normal cascade and makes handling styles more difficult. Always try to keep the styling in the css Which is best achieved by manipulating an appropriate class.

Yes that will work fine on touch.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.