Update the Navbar links to smoothly slide along the navigation bar as the width decreases, instead of awkwardly

When in full screen, the Navbar links are displayed horizontally.

https://i.stack.imgur.com/0mOLp.png

However, when the width changes, they appear like this

https://i.stack.imgur.com/2ylgZ.png

Is there a way to ensure they shift to the left while maintaining their horizontal layout?

HTML

<nav>
<h1 id=>Nav</h1> <div id="NHide">   
<ul>
    <li><a class="NavL" href="#slide1" title="Sample Text">Slide 1</a></li>
    <li><a class="NavL" href="#slide2" title="Sample Text">Slide 2</a></li>
    <li><a class="NavL" href="#slide1" title="Sample Text">Slide 3</a></li>
    <li><a class="NavL" href="#slide1" title="Sample Text">Slide 4</a></li>
</ul>
</nav>

CSS

#NHide{
position:absolute;
left:77%;
top:0%;    
}   

nav {
position: fixed;
z-index:1;    
font-size: 24px;
width: 100%;
line-height: 48px;
height: 48px;
background: #000;
text-align: left;
font-family: 'PT Sans', sans-serif;
color: #fff;
} 

ul { 
list-style-type: none;
margin: 0;
padding: 0;
float:left;
}

li {
display:inline-block;
}

.NavL {
display: block;
width: 100px;
}

Answer №1

To customize this CSS, you need to make some adjustments:

#NHide{
  float:right;
}   

Alternatively, you can use the following code (although the previous option is recommended):

#NHide{
  position:absolute;
  right: 0;
  top:0;
}

The reason for this change is that maintaining a fixed 77% position from the left may cause wrapping issues, especially if your navigation bar is too wide to fit on one line.

If these solutions do not resolve the issue, consider providing a working example on a platform like http://jsfiddle.net.

Answer №2

If you're looking to align your links to the right side of the navigation bar, simply adjust the CSS properties by setting right: 0 and removing the left: 77%

Check out this fiddle for reference

#NHide{
    position: absolute;
    right: 0;
    top: 0%;    
} 

Answer №3

Implement this code snippet into your CSS

#NHide
{
position:absolute;
right:0px;
top:0%;    
}   
h1#headnav
{
position:absolute;
left:0px;
top:-28px;
}

Include the following line in your HTML code

<h1 id="headnav">Nav</h1> 

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

Update options in HTML form dropdowns dynamically based on selections from other dropdowns using Node.js

In my Node.js application, I have the following file system structure: public elegant-aero.css stadium-wallpaper.jpg team-results.html public.js app.js teamresults.mustache I am trying to dynamically populate a dropdown menu based on user sele ...

The media does not need to be applied to the ".nav__btn" class

How can I hide an element with the ".nav__btn" class by setting its display to none when the screen width is at least 768px? I tried the following media code but it doesn't work. Media Code @media (min-width: 768px) { .nav__btn { display: ...

In Firefox, the focus outline is not shown on a div that has a mask-image CSS rule applied to

In my code, I have multiple div elements that have the mask-image and -webkit-mask-image CSS rules applied to them. These divs are being used as UI slider components, so I want keyboard users to be able to tab between them and use the arrow keys to adjust ...

Blog Format Featuring Side-by-Side Columns

Is there a way to achieve horizontal columns that don't cut off articles and flow seamlessly into the next column? I want the columns to have varying heights, such as Post A at 60% height, followed by Post B at 40% height, then Post C at 30%, and fina ...

The section cannot be shown in a flex layout within a grid container

My goal is to showcase a grid layout containing multiple sections within a div, but I'm encountering an issue where the sections are only displaying as blocks. I am seeking assistance in making the second portion of the data appear flexed. Currently, ...

Finding your site's First Contentful Paint (FCP) can be done by analyzing the

After doing some research on Google insights, I came across information about FCP. However, I'm still unsure about how to determine my site's FCP and other relevant metrics. If anyone could provide me with more information or share detailed link ...

Creating a dynamic form in Angular based on user input

I am in the process of creating a dynamic web form where the user's input will determine the subsequent form inputs that are generated. For example: <mat-form-field> <mat-select placeholder="Type" [(ngModel)]="row.Type" (change)="Typ ...

Setting header details for optimal data transfer

Currently, there is a Java code snippet that I am working on which attempts to access the header information sent by an HTML page. Unfortunately, I do not currently have the specific HTML page in question. However, I still need to be able to access and m ...

Ensures that two divs have the same dimensions

Currently, I have a line of sections set up like this: I am attempting to ensure that the second div matches the height of the first one, despite the fact that their heights are determined by the size of the pictures which may vary. Do you have any sugges ...

Text randomly appears on the html page

I've been dedicating a significant amount of time to finding a solution, but haven't had any luck. I'm aiming to create a visual effect where 10 words with varying font sizes slide in from different directions on a canvas within my document ...

JQuery - ToggleMenu - 3 different menus nested under 3 separate div containers

Currently, I have three menu buttons displayed horizontally. When one button is clicked, three links slide down below it. Clicking on another button will slide up the first set of links and slide down a different set. (view example here) My goal is to hav ...

Incorporate JSON data into a subsequent AJAX call when coding in JavaScript

I am facing an issue where I need to use data returned from an ajax request to construct a string and then post it back using ajax. However, the variable I'm assigning the data to is not within the scope of the second request, resulting in a 'var ...

Retrieving a boolean value (from a JSON file) to display as a checkbox using a script

Currently, I am utilizing a script to fetch data from a Google Sheet $.getJSON("https://spreadsheets.google.com/feeds/list/1nPL4wFITrwgz2_alxLnO9VBhJQ7QHuif9nFXurgdSUk/1/public/values?alt=json", function(data) { var sheetData = data.feed.entry; va ...

Only initiate the loading of the iframe within the div upon clicking a specific element

Is there a way to delay loading the content of a div until it's clicked, instead of having all data loaded at once when the page loads? I noticed that removing unnecessary divs made the page load much faster. How can I prevent all data from being loa ...

I am looking to navigate between tabs on a multi-part form in order to submit all the form data

My current form consists of five questions, each on a separate tab. What I am trying to achieve is the following: When the user submits the form data on the fifth tab An Ajax request sends the form data to a background script for processing Simultaneousl ...

Guide on integrating a jQuery confirmation popup in CodeIgniter

Currently, I am working on a project independently and have chosen CodeIgniter as my framework. I am relatively new to PHP and CodeIgniter. I managed to create a confirm box in jQuery, but it displays as an HTML alert. Can someone guide me on how to improv ...

Obtain a set of items from a JSON result and transfer them to the database

I have a table that displays object data triggered by a dropdownbox .change function. However, I also need to submit this data to a database. While I can display the data when the dropdown changes, I'm struggling with retrieving the list of objects an ...

Jquery experiencing compatibility issues with Internet Explorer

I created this jQuery function to check a PHP page and display the result. It works perfectly in other browsers, but unfortunately I am experiencing issues with Internet Explorer (IE). This is concerning because most users use IE as their browser. $(docum ...

Submitting a form into a database with the help of AJAX within a looping structure

Trying to input values into the database using AJAX. The rows are generated in a loop from the database, with each row containing a button column. Clicking on the button submits the values to the database successfully. The issue is that it only inserts va ...

The Ajax POST functionality appears to be malfunctioning, whereas the PHP equivalent is operating without any

Need assistance in developing a JavaScript mobile app that will POST an authentication token to a Microsoft website. Attempting to use online JavaScript code found, but encountering failures. The JavaScript code outputs a message "GET undefined/proxy/htt ...