Sideways collapsing navigation bar with links sliding to the right

As I work on developing a horizontal menu, I encountered an issue with the expanding animation when clicking on the bento menu. Instead of smoothly transitioning to the right, the links are initially stacked up and then eventually align in a single line which looks unappealing. I suspect this is due to setting the width as 0px when the menu is closed. Can someone provide guidance on a better approach to achieve a smooth transition where the links shift to the right without the awkward stacking animation?

function navMenu()
{
    var classToggle = document.getElementById("navLinks");
    if (classToggle.className === "navMenuClosed") {
      classToggle.className = "navMenuOpen";
    } else {
      classToggle.className = "navMenuClosed";
    }

}
.bento-menu {
  float: left;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  grid-column-gap: 2px;
  grid-row-gap: 2px;
  height: 22px;
  width: 22px;
  cursor: pointer;
}
.bento-dot {
  width: 6px;
  height: 6px;
  background: #ff0000;
  overflow: hidden;
}
#navLinks {
  line-height: 22px;
  background-color: brown;
  float: left;
}
.navMenuOpen {
  width: 500px;
  opacity: 1;
  transition: width 2s;
}
.navMenuClosed {
  width: 0px;
  opacity: 0; 
  overflow-x: hidden;   
}
#navLinks li {
  display: inline;
  margin-right: 30px;
}
#navLinksUl {
  margin: 0;
  list-style: none;
}
.test {
  border: darkblue solid 10px;
}
<html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="/test/navbar.css" /> </head> <body> <div id="navbar"> <div class="bento-menu" onclick="navMenu()"> <div class="bento-dot"></div> <div class="bento-dot"></div> <div class="bento-dot"></div> <div class="bento-dot"></div> <div class="bento-dot"></div> <div class="bento-dot"></div> <div class="bento-dot"></div> <div class="bento-dot"></div> <div class="bento-dot"></div> </div> <div id="navLinks" class="navMenuClosed"> <ul id="navLinksUl"> ...

Answer №1

If you're looking to enhance #navLinks in your CSS, consider including the following properties: text-overflow. Researching this property and others can greatly benefit your navigation design.

#navLinks {
  text-overflow: clip;
  white-space: nowrap;
  overflow: hidden;
}

I trust this information proves useful! :)

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

What is the best way to position a div below another sticky div when the first div's height is constantly changing

I am facing a challenge with scrollable text and sticky headers on my webpage. The top text has dynamic height based on the content below, which is followed by a sticky header with its own dynamic height. Now, I want to add another sticky header below the ...

The error message in Next.js states: "Attempting to access properties of undefined (specifically trying to access 'indexOf')."

After successfully running the code below, I encounter an issue upon refreshing the page: TypeError: Cannot read properties of undefined (reading 'indexOf'). const [folders, setFolders] = useState([]); const [user] = useAuthState(auth); c ...

"Disappearing act: Navigating through pages causes the navigation

Struggling with navigation in my asp.net core web app development. My directory structure includes the use of Areas. https://i.sstatic.net/DL6qe.png https://i.sstatic.net/GeEg9.png When navigating through pages in the main folder like Index, Index1, and ...

An issue has arisen with AngularJS and Twitter Bootstrap, displaying an error message stating that the function element.focus

I recently implemented the angularjs twitter bootstrap datepicker and everything seemed to be working smoothly. However, I encountered an error when trying to click on the text box for the popup datepicker. This issue has left me puzzled as I am still new ...

Attributes declaration in HTML5

Struggling with incorporating custom attributes in an HTML5 document. The initial snippet of my source code looks like this: <!DOCTYPE html [ <!ATTLIST img pid ID #IMPLIED> ]> During validation of my HTML file using the W3C validator, it fai ...

Tips for displaying an alert in the upcoming event loop

I recently started learning VueJS and decided to create a practice game to strengthen my understanding of the framework. http://jsfiddle.net/mzref4o0/1/ Within this game, the attack method is crucial in determining the winner: attack: function(isSpecial ...

Can HTML be incorporated into a (React) Three.js Decal?

I posted this question on the Three.js Discourse forum as well. In a CodeSandbox example from drcmda's documentation, I want to enhance the text decal with HTML content. For instance, including something like the following right after the <Text> ...

What is the process for loading data with no input provided?

I have come across a situation where my HTML table is populated with various account numbers. https://i.sstatic.net/qJc2E.png When I input the account number 979545130406, the filter works perfectly fine. https://i.sstatic.net/Y4Rwk.png However, the is ...

React-slick slider not functioning properly when using TypeScript

I encountered an issue while trying to implement a carousel/slider using the typescript version of the react-slick library in my Nextjs project. After importing the Slider component from the package, I received the following error: https://i.sstatic.net/6 ...

The link appears to be broken when trying to access the notFound component in Next.js version 13

In my Next.js 13.4 app directory, I added a not-found.tsx component that functions correctly when entering the wrong route: import Link from 'next/link' function NotFound() { return ( <section> 404, page not found ...

Items positioned above the FlatList remain static on the screen and do not move along with the scrolling of the FlatList

I have a situation where I have a flatlist element positioned after another element. When I scroll up, the element before the flatlist remains fixed in its position. Is there a way to make it move up along with the flatlist when scrolled? For example: ...

Tips for directing attention to a specific row with an input field in JavaScript

I duplicated a table and added an input field for users to search or focus on a specific row. However, there are two issues: When a user enters a row number, the table displays the wrong row - for example, if the user enters 15, the table shows row number ...

Is it possible to incorporate some scripting to enhance the efficiency of deploying my mongoose database?

I'm completely new to setting up servers and diving into back-end development. My technical language is limited, making it challenging to find solutions through online research. I apologize in advance for my lack of expertise in this area. Currently, ...

Retrieving images from GridFs and displaying them in an Angular application

I have been working on storing images from my angular app in MongoDB using GridFs. However, I am having trouble retrieving the images from the database to the app. I am using a custom objectId for the query. UPDATE After some changes, I managed to get t ...

Using w3-include-html with a relative URL path

Is there a way for me to use the same header HTML on multiple pages within subdirectories without having to duplicate the file itself? As shown in the code snippet below, the header file is located in both the current directory and parent directory. While ...

I'm struggling to find the perfect configuration for Vite, JSconfig, and Aliases in Visual Studio Code to optimize Intellisense and Autocomplete features

After exclusively using PHPStorm/Webstorm for years, I recently made the switch back to Visual Studio Code. The main reason behind this decision was the lightweight nature of VSCode and its widespread availability as a free tool, unlike paid services. I s ...

How can I correctly parse nested JSON stored as a string within a property using JSON.parse()?

I am having trouble decoding the response from aws secretsmanager The data I received appears as follows: { "ARN": "arn:aws:secretsmanager:us-west-2:0000:secret:token-0000", "Name": "token", "VersionId&qu ...

Having trouble retrieving the property from the object that was returned

I'm facing a challenge where I'm unable to properly query the JSON response I receive. However, I can successfully print out the entire response using a msgBox() prompt. Here's an excerpt of the JSON response that I managed to see through th ...

What is the best way to access the inner html of every cell within a table row that I have selected?

I want to implement a feature on my website where users can click a "save" button on a specific row in a table and save the entire row's innerHtml onto another page as their favorite hiking trails. I've been trying to achieve this by adding clic ...

Tips for maintaining the state of a page submitted via Turbolinks using Rails 5 and jQuery

My current challenge involves toggling the visibility of a section when a specific element is clicked. Initially, I was able to achieve this functionality successfully. However, complications arose as my application revolves around a todo list where tasks ...