So,i'm creating a website design,and i want to change my navigation bar position from right top to left top,and want to change the navigation bar opening animation to the the opposite direction. I mean the whole navigation bar will be on the top right side.

I don't have too much experience in the CSS and web development, so please help me i need this to my school project. Thank you everyone! Here is the code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
     
    <style>
    
body {
  
    font-family: 'Roboto Condensed', sans-serif;  
  font-size: 16px;
    overflow: hidden;
    text-transform: uppercase;
    font-weight: bold;
}
.menu {
  height: 70px;
  width: 70px;
  right: 70px;
  top: 20px;
  text-align: center;
  position: absolute;
  background: #f463c3;
  overflow: hidden;
  transition: all 0.2s ease;
  z-index: 999;
}
.menu.active {
  width:85%;
  transition:width 0.3s;
   -webkit-transition:width .3s;
   -moz-transition: width 0.3s;
    
}
.menu.active .menuContent * {
  opacity: 1;
}
.menu.active span i:nth-child(1) {
  transform: rotate(-45deg) translate(-50%, -50%);
  top: 50%;
}
.menu.active span i:nth-child(2) {
  transform: translateX(-100px);
  opacity: 0;
}
.menu.active span i:nth-child(3) {
  transform: rotate(45deg) translate(-50%, -50%);
  top: 50%;
}
.menu span {
  width: 70px;
  height: 70px;
  position: absolute;
  right: 0;
  cursor: pointer;
  background: #f463c3;
  z-index: 1;
}
.menu span i {
  position: absolute;
  transform-origin: 50% 50%;
  width: 45%;
  height: 2px;
  left: 0;
  right: 0;
  margin: auto;
  background-color: #ccc;
  transition: transform 0.3s ease, opacity 0.1s ease 0.1s;
}
.menu span i:nth-child(1) {
  top: 40%;
}
.menu span i:nth-child(2) {
  top: 50%;
}
.menu span i:nth-child(3) {
  top: 60%;
}
.menu .menuContent {
  position: absolute;
  width: 100%;
  height: 100%;
  line-height: 40px;
  right: 0px;
  text-align: center;
}
.menu .menuContent * {
  opacity: 0;
}
.menu .menuContent ul li {
  display: inline-block;
  margin-left: 50px;
  margin-right: 50px;
  color: #2d3235;
  transition: opacity 0.3s ease 0.3s;
  cursor: pointer;
  position: relative;
}
.menu .menuContent ul li:hover:before {
  opacity: 0.8;
  top: 13px;
  left: 20px;
}
.menu .menuContent ul li:hover:after {
  opacity: 0.8;
  bottom: 13px;
  left: -20px;
}
        
    </style>
</head>
<body>
    <div class='menu'>
  <span class='toggle'>
    <i></i>
    <i></i>
    <i></i>
  </span>
  <div class='menuContent'>
    <ul>
      <li>Home</li>
      <li>About</li>
      <li>Contact</li>
      <li>Testimonial</li>
      <li>About us</li>
    </ul>
  </div>
</div>
 
<script
  src="https://code.jquery.com/jquery-3.3.1.js"
   ></script>
<script>
    $('.toggle').on('click', function() {
 $('.menu').toggleClass('active');
});
    
</script>
</body>
</html>

2 Answers

0
Lemon Kazi On

I think below code will help you. transform: rotate(-145deg) for child 1 and transform: rotate(145deg) translate(-50%, -50%); for child 3

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
     
    <style>
    
body {
  
    font-family: 'Roboto Condensed', sans-serif;  
  font-size: 16px;
    overflow: hidden;
    text-transform: uppercase;
    font-weight: bold;
}
.menu {
  height: 70px;
  width: 70px;
  left: 70px;
  top: 20px;
  text-align: center;
  position: absolute;
  background: #f463c3;
  overflow: hidden;
  transition: all 0.2s ease;
  z-index: 999;
}
.menu.active {
  width:85%;
  transition:width 0.3s;
   -webkit-transition:width .3s;
   -moz-transition: width 0.3s;
    
}
.menu span {
width: 70px;
height: 70px;
position: absolute;
right: 0;
cursor: pointer;
background: #f463c3;
z-index: 1;
left: 0;
}
.menu.active .menuContent * {
  opacity: 1;
}
.menu.active span i:nth-child(1) {
  transform: rotate(-145deg) translate(-50%, -50%);
   top: 50%;
}
.menu.active span i:nth-child(2) {
  transform: translateX(-100px);
  opacity: 0;
}
.menu.active span i:nth-child(3) {
  transform: rotate(145deg) translate(-50%, -50%);
  top: 50%;
}
.menu span {
  width: 70px;
  height: 70px;
  position: absolute;
  right: 0;
  cursor: pointer;
  background: #f463c3;
  z-index: 1;
}
.menu span i {
  position: absolute;
  transform-origin: 50% 50%;
  width: 45%;
  height: 2px;
  left: 0;
  right: 0;
  margin: auto;
  background-color: #ccc;
  transition: transform 0.3s ease, opacity 0.1s ease 0.1s;
}
.menu span i:nth-child(1) {
  top: 40%;
}
.menu span i:nth-child(2) {
  top: 50%;
}
.menu span i:nth-child(3) {
  top: 60%;
}
.menu .menuContent {
  position: absolute;
  width: 100%;
  height: 100%;
  line-height: 40px;
  right: 0px;
  text-align: center;
}
.menu .menuContent * {
  opacity: 0;
}
.menu .menuContent ul li {
  display: inline-block;
  margin-left: 50px;
  margin-right: 50px;
  color: #2d3235;
  transition: opacity 0.3s ease 0.3s;
  cursor: pointer;
  position: relative;
}
.menu .menuContent ul li:hover:before {
  opacity: 0.8;
  top: 13px;
  left: 20px;
}
.menu .menuContent ul li:hover:after {
  opacity: 0.8;
  bottom: 13px;
  left: -20px;
}
        
    </style>
</head>
<body>
    <div class='menu'>
  <span class='toggle'>
    <i></i>
    <i></i>
    <i></i>
  </span>
  <div class='menuContent'>
    <ul>
      <li>Home</li>
      <li>About</li>
      <li>Contact</li>
      <li>Testimonial</li>
      <li>About us</li>
    </ul>
  </div>
</div>
 
<script
  src="https://code.jquery.com/jquery-3.3.1.js"
   ></script>
<script>
    $('.toggle').on('click', function() {
 $('.menu').toggleClass('active');
});
    
</script>
</body>
</html>

0
John Nguru On

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
     
    <style>
    
body {
  
    font-family: 'Roboto Condensed', sans-serif;  
  font-size: 16px;
    overflow: hidden;
    text-transform: uppercase;
    font-weight: bold;
}
.menu {
  height: 70px;
  width: 70px;
  left: 70px;
  top: 20px;
  text-align: center;
  position: absolute;
  background: #f463c3;
  overflow: hidden;
  transition: all 0.2s ease;
  z-index: 999;
}
.menu.active {
  width:85%;
  transition:width 0.3s;
   -webkit-transition:width .3s;
   -moz-transition: width 0.3s;
    
}
.menu.active .menuContent * {
  opacity: 1;
}
.menu.active span i:nth-child(1) {
  transform: rotate(-45deg) translate(-50%, -50%);
  top: 50%;
}
.menu.active span i:nth-child(2) {
  transform: translateX(-100px);
  opacity: 0;
}
.menu.active span i:nth-child(3) {
  transform: rotate(45deg) translate(-50%, -50%);
  top: 50%;
}
.menu span {
  width: 70px;
  height: 70px;
  position: absolute;
  left: 10px;
  cursor: pointer;
  background: #f463c3;
  z-index: 1;
}
.menu span i {
  position: absolute;
  transform-origin: 50% 50%;
  width: 45%;
  height: 2px;
  left: 0;
  right: 0;
  margin: auto;
  background-color: #ccc;
  transition: transform 0.3s ease, opacity 0.1s ease 0.1s;
}
.menu span i:nth-child(1) {
  top: 40%;
}
.menu span i:nth-child(2) {
  top: 50%;
}
.menu span i:nth-child(3) {
  top: 60%;
}
.menu .menuContent {
  position: absolute;
  width: 100%;
  height: 100%;
  line-height: 40px;
  right: 0px;
  text-align: center;
}
.menu .menuContent * {
  opacity: 0;
}
.menu .menuContent ul li {
  display: inline-block;
  margin-left: 50px;
  margin-right: 50px;
  color: #2d3235;
  transition: opacity 0.3s ease 0.3s;
  cursor: pointer;
  position: relative;
}
.menu .menuContent ul li:hover:before {
  opacity: 0.8;
  top: 13px;
  left: 20px;
}
.menu .menuContent ul li:hover:after {
  opacity: 0.8;
  bottom: 13px;
  left: -20px;
}
        
    </style>
</head>
<body>
    <div class='menu'>
  <span class='toggle'>
    <i></i>
    <i></i>
    <i></i>
  </span>
  <div class='menuContent'>
    <ul>
      <li>Home</li>
      <li>About</li>
      <li>Contact</li>
      <li>Testimonial</li>
      <li>About us</li>
    </ul>
  </div>
</div>
 
<script
  src="https://code.jquery.com/jquery-3.3.1.js"
   ></script>
<script>
    $('.toggle').on('click', function() {
 $('.menu').toggleClass('active');
});
    
</script>
</body>
</html>