Navigating through a diagonal path

Struggling to craft a diagonal navigation system similar to the images below. Despite its seemingly simplicity, I'm stuck investing too much time in figuring it out. My goal is for the menu container to smoothly reveal from right to left when clicking on the hamburger icon. The main challenges lie in handling the navbar change and ensuring a fluid animation for the menu container—is it best for the menu items to remain in place or slide as they appear?

To summarize my dilemmas:

  1. How can I achieve this design effectively?
  2. Is duplicating the navbar section necessary?
  3. What's the best way to reveal the underlying content?

Any guidance on this matter would be greatly appreciated.

https://i.sstatic.net/KhAUw.png https://i.sstatic.net/kKnyo.png

Below is the code snippet I've experimented with:

.hamburger {
    z-index: 1001;
    position: absolute;
    right: 0;
    top: 0;
    width: 100px;
    height: 100px;
    overflow: hidden;
    #hamburger {
        z-index: 1;
        position: relative;
        top: 18px;
        left: 25px;
    }
    .line {
        width: 24px;
        height: 2px;
        background-color: #fff;
        display: block;
        margin: 6px auto;
        position: relative;
        z-index: 2;
        transition: all 0.3s ease-in-out;
    }
    &:hover {
        cursor: pointer;
    }
    &:after {
        width: 180px;
        height: 180px;
        display: block;
      
        background: black;
        content: '';
        right: 0;
        top: 0;
        transform: rotate(45deg) translate(-50%, -63%);
    }
}

#hamburger.is-active .line {
    z-index: 1001;
  &:nth-child(2) {
    opacity: 0;
  }
  &:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }
  &:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }
}

.nav_container {
    width: 200%;
    height: 100%;
    background: black;
    z-index: 1000;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    transform: skew(45deg);
    transition: opacity 300ms ease-in-out;
    opacity: 0;
}

.nav_container.is-open {
    display: block;
    opacity: 1;
}

.navigation-menu {
    background-color: transparent;
    pointer-events: none;
    min-height: 100%;
    position: absolute;
    width: 100%;
    // transform: translateX(150%);
    transform: skew(-45deg);

    > * {
        pointer-events: auto;
    }
  
    &--open {
        transform: translateX(0);
        
        & .navigation-menu__bars {
          background-color: transparent;
          
          &::before,
          &::after {
            top: 0;
          }
        
          &::before {
            transform: rotate(45deg);
          }
    
          &::after {
            transform: rotate(-45deg);
          }
        }
        
        .menu-list__item {
          opacity: 1;
        }
        
        $menu-delay: 1s;
        @for $i from 1 through 12 {
          .menu-list__item:nth-child(#{$i}) {
            transition-delay: $menu-delay;
          }
          $menu-delay: $menu-delay + .25s;
        }
    }
}
<div class="hamburger">
    <div id="hamburger"><span class="line"></span><span class="line"></span><span class="line"></span></div>
</div>
<div class="nav_container">
    <nav class="navigation-menu js-nav-menu">
        <div class="navbar__menu">
            <ul>
                <li class='title'><a href="">Home</a></li>
                <li><a href="">One</a></li>
                <li><a href="">Two</a></li>
            </ul>
            <ul>
                <li class='title'><a href="">Home</a></li>
                <li><a href="">One</a></li>
                <li><a href="">Two</a></li>
            </ul>
        </div>
    </nav>
</div>

My CSS is in SCSS format, so it might not compile but gives an idea of my progress. Any assistance would be highly valued.

Answer №1

Simply implement the CSS clip-path property and unlock endless styling possibilities. If you need guidance, refer to the Mozilla documentation, or try out this helpful clip path generator

Stay creative

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

PHP form - The issue with validation not functioning properly

I'm having trouble validating a simple PHP form with HTML code and it's not working as expected. Here is the HTML code: <form action="expresscontactform.php" method="post" name="form1" id="form1"> <label>Name </label>< ...

Images that are automatically generated cannot be interacted with by clicking on them

I currently have 4 images loaded onto my website. Whenever I click on one of the images, it becomes highlighted as desired using the following code: JavaScript Function 1 : var ImageSelector = function() { var imgs = null; var selImg = null; retu ...

Guide to displaying the output of a JS calculation in a Bootstrap modal dialog box

I have a HTML and JavaScript code that determines the ideal surfboard for the user based on their input data (style, experience, height, weight) and displays the recommended surfboard type. Here is the initial code snippet I attempted to use: function c ...

Optimizing the management of optional post fields in an Express.js application

When creating an endpoint with Express that includes both mandatory and non-mandatory fields in the post request, what is the optimal strategy for handling this? Would it be best to use something like if (field exists in req.body) { set variable } else { ...

Once the GeoJson data is loaded with map.data.loadGeoJson, the circle events are obscured by the polygons from the

When I use map.data.loadGeoJson() to load a Geo Json file, the markers and circles on my map are being covered by polygons and their events cannot be clicked. Below are some sample codes for reference. How can this issue be resolved? Is there another way ...

What is the best approach to defining a type for a subclass (such as React.Component) in typescript?

Can someone help me with writing a type definition for react-highlight (class Highlightable)? I want to extend Highlightable and add custom functionality. The original Highlightable JS-class is a subclass of React.Component, so all the methods of React.Com ...

Adjust the form input box height to a different size

Is there a way to adjust the height of the form input box so that the text is positioned close to the top and bottom borders of the box? I attempted to modify the CSS but was unsuccessful. Any suggestions for a Bootstrap CSS solution would be greatly appre ...

My code seems to be malfunctioning

I'm attempting to conceal the chatname div. Once hidden, I want to position the chatid at the bottom, which is why the value 64px is utilized. However, I encountered an error stating The function toggle3(); has not been defined. <div id="chat ...

Tips for creating seamless image transitions using a toggle button

My transition effect is working smoothly, but I am having trouble setting it up for the image. How can I resolve this issue? I attempted the following: var lightsOff = document.querySelector("#lights-off"); var lightsOn = document.querySelector("#lights-o ...

ReactJS sidebar navigation functionality

I have a fixed sidebar with icons for navigating to different pages. When an icon is clicked, a secondary menu slides out. However, the issue is that when another icon is selected, the menu slides back in instead of switching or staying out. Additionally, ...

The scrolling speed of the mousewheel in Firefox is notably slower compared to that of Google Chrome

Kindly review this sample link: When I test the above example in Chrome and scroll using the mouse wheel, the page moves up by 100px each time. The Y position is displayed as well. However, if I try the same page in Firefox 26.0 and scroll with the mouse ...

Displaying a specific division solely on mobile devices with jQuery

I need to implement a feature where clicking on a phone number div triggers a call. However, I only want this div to be displayed on mobile devices. To achieve this, I initially set the div to "display:none" and tried using jQuery to show it on mobile devi ...

A guide on obtaining the pixel dimensions of a ThreeJS mesh object: determining its visible width and height

I am currently grappling with the task of determining the visible view width and height of a ThreeJS mesh object in pixel units. In the image provided below, you can observe objects suspended in 3D space. Upon clicking the mouse, I need to be able to disc ...

Div sliding out of view

I'm encountering a slight issue with this template: essentially, my goal is to implement a feature where clicking on a box will expand it while simultaneously sliding the other boxes off-screen. However, instead of just sliding the div off-screen, it ...

Puppeteer does not support the use of multiple proxies concurrently

How can I effectively set up multiple proxies with puppeteer? Here is the approach I have taken: const puppeteer = require('puppeteer'); (async () => { let browsers = []; const proxies = [ 'socks5://myuser: ...

svg icon hover effect not displaying color properly

Seeking expertise in incorporating social media icons with a hover effect to turn purple. Encountering an issue where the entire circle of the icon is mistakenly being painted on hover. Refer to the screenshot of the current outcome and desired result. Wo ...

Issue with Chart.js not showing up in Android Webview when animation is disabled

I am experiencing an issue with a javascript enabled WebView using a ChromeWebClient. The Chart.Js pie example displays fine until I set the options to animation: false, after which the chart stops displaying. var pieOptions = { animation : fa ...

Utilize jQuery to wrap text within <b> tags and separate them with <br> tags

Upon receiving output in html string format from services, I am presented with the following: "<html>↵<h1>↵Example : ↵<br>Explanation↵</h1>↵<hr>↵<b>key1 : ABCD <br>key2 : 2016-10-18-18-38-29<br> ...

retrieve the index from the chosen elements

Hey there! I'm facing a situation where I have a div with several child elements. Using jQuery, I want to find the index of a specific element within a certain selector. <div> <div class="red"></div> <div class="red"></ ...

What is causing the sorting table to fail in React when using useState?

import React, { useState } from "react"; import "./App.css"; const App = () => { const [data, setData] = useState([ { rank: 1, name: "John", age: 29, job: "Web developer", }, { rank: 2, name: "Micha ...