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

Embracing the Unknown: Exploring Wildcard Values

I have a code snippet below that has a wildcard * in it. I'm looking for suggestions on how to make the * accept any number. Any thoughts on this? $('body').on('click', '.custom_295_*-row', function(){ var href = "htt ...

Approach to CSS Layout: Creating Rounded Corners without CSS3 using images on all sides

I am faced with the challenge of creating a CSS layout that must adhere to specific minimum width and height requirements, yet expand to occupy 80% of the browser size. The main div I need to design should have rounded corners, utilizing images due to lack ...

Is there a way in CSS to enable caps lock for specific characters only?

After downloading a new font and setting font-variant: small-caps;, I noticed that my numbers appear much larger than the letters. Is there a way to apply small caps only to the letters, not the numbers? While traditionally numbers do not have a capital ...

What is the best way to show a left and right arrow on a mobile website page?

I'm experiencing a strange issue with my webpage, specifically a post in Wordpress. When I try to insert the left right arrow character (U+2194) either by copying from a character map or using the html code, I end up with an icon instead of the actual ...

CSS Grid expands the item width on its own when there is still space left

Having some queries regarding the piece of code provided. Currently, I have a collection of 5 cards displayed in rows of 3 cards each using the styling grid-template-columns: repeat(3, minmax(200px, 1fr));. My concern is whether there is a way for the 4th ...

How can JavaScript nested AJAX requests and promises be properly chained together?

I'm currently facing a dilemma when it comes to setting the correct order of execution for the tasks at hand. Let's say I need to initiate an AJAX call, then handle the data and store it in IndexedDB using the idb-keyval library, which operates o ...

What is the best way to insert HTML elements onto a webpage and retrieve them in an asp.net environment?

Greetings, For the past day, I've been attempting to dynamically add elements to a web page using Visual Studio and access their values. Either I'm overthinking things, being foolish, or there just isn't a straightforward way to achieve wha ...

Guide for displaying SQL data in an HTML table

I am currently working on transferring my SQL data to an HTML format. The code I have so far is not functioning as expected. I attempted to include HTML within my PHP code, and now I am considering if it would be better to do it the other way around (emb ...

Incorrect color change on button triggered by onMouse actions and state fluctuations

While creating a user profile on my app, I encountered an issue with button coloring. When I try to add color functionality to the button, it turns red instead of green and remains red even when the mouse is not hovering over it. My goal is to have the but ...

Is the POST AJAX request being rejected due to CORS restrictions?

I have configured CORS on my node.js server running on port 5000 in the following way: var app = express(); app.use(cors()); //normal CORS app.options('*', cors()); //preflight app.post('/connect', function(req, res) { console ...

Include a picture and a division element within the dropdown element

I've encountered a few challenges while trying to personalize a profile dropdown component using Semantic and React. First, I am facing an issue where my application crashes when I attempt to place a div inside the Dropdown.Menu with the error message ...

Error message saying "Jquery/Ajax Variable is undefined"

Whenever I try clicking the button, an error pops up saying "popup is not defined." I have no clue what to do. <input href="#dialog" type='button' value='Open' onclick="popup(<?php echo $image['image_id']; ?>); retur ...

Is there a jQuery character count function that includes all characters, including ENTER and other special characters

Typically, the goal is to remove these, but I require the actual character count and am struggling to find a way to obtain it... Appreciate your assistance ...

Customizing the appearance of ASP.NET file uploader for various sizes

Has anyone successfully changed the width of the ASP.NET file uploader? I attempted by adding the CssClass, but it did not work. Is there an alternative method to adjust the width? Thanks in advance. ...

The AudioContext feature is functioning properly on Google Chrome but experiencing issues on Safari

In Safari, I understand that audio context needs to be created after user interaction. Despite this knowledge, the code below still didn't produce the desired result. HTML <button onclick="play">Play</button> Javascript functio ...

What is the best way to extract text from a list item in an unordered list (

I am trying to search a ul list that populates a ddSlick dropdown box. ddSlick adds pictures to list items, making it a visually appealing choice. To see more about ddSlick, you can visit their website here: Here is the code I am using to loop through the ...

Having trouble with getting data from Google API using jquery .get in IE9?

Having trouble understanding why this code works perfectly in Firefox but not in IE9. The script is designed to retrieve values such as street, postcode, and town from a form upon clicking a button. It then constructs a string, sends it to Google, retriev ...

Velocity.js causing a slowdown in animated performance

Currently, I am attempting to animate spans, and while the animation is functional, it appears to be somewhat choppy and lacks smoothness. https://codepen.io/pokepim/pen/JBRoay My assumption is that this is due to my use of left/right for animation purpos ...

Change HTML to PDF with the ability to split text at page breaks

I recently attempted to convert an HTML/CSS document into a PDF file using the pdflayer.com API. Everything seemed to be working well, but I encountered a problem with line breaks splitting lines, as shown in this photo: https://i.sstatic.net/1tqKM.jpg I ...

Ways to conceal the TippyJS tooltip so it doesn't show up on video embeds

My website has tooltips enabled, but I am looking to hide the tooltip pop-ups that appear specifically over youtube video embeds. Upon inspecting the webpage, I found the code snippet below that is associated with youtube videos: <div data-tippy-root id ...