When the browser is resized, the menus will automatically drop down

I am experiencing an issue with my horizontal menu bar code.

The menu bar displays correctly for the resolution 1366 x 768,

but when I press the ctrl - shortcut key and reduce the browser size using the same shortcut key, my menus move down. I have tried both em and px units to address this problem but it doesn't seem to resolve it. It's important that the menu bar remains in the center, like the other elements on the page, and expands to fit the 960px wrapper setting. I need assistance in solving this issue.

Below is the source code:

HTML

<nav>
  <div class="nav_wrapper">
    <div class="menu_box">
      <div id='cssmenu'>
        <ul>
          <li><a href='index.php' class="active"><span>Home</span></a></li>
          <li><a href='#'><span>About Us</span></a></li>
          <li><a href='#'><span>Courses</span></a>
            <ul>
              <li><a href='index.php'>AGP Program</a></li>
              <li><a href='index.php'>Web Program</a></li>
            </ul>
          </li>
          <li><a href='#'><span>Partners</span></a></li>
          <li><a href='#'><span>Consultancy</span></a></li>
          <li><a href='#'><span>News n Events</span></a></li>
          <li><a href='#'><span>Gallery</span></a></li>
          <li><a href='#'><span>Contact</span></a></li>
        </ul>
      </div>
    </div>
  </div>
</nav>

CSS

/* CSS rules go here */


Answer №1

To address this issue, I simply added a min-width property to one of the wrapping elements. In my experience, applying it to "nav_wrapper" yielded better results. It's also important to note that when dealing with an element larger than the display, it's beneficial to eliminate any margin in the body element, so I made that adjustment as well.

Below are the modifications I implemented:

Custom CSS

body{
        margin: 0px;
    }
.nav_wrapper{
        min-width: 980px;
}

VIEW LIVE DEMO

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

Require assistance resolving a CSS problem on IE8?

Greetings everyone, I am currently facing some compatibility issues with my style sheets, particularly in IE 8. The CSS code below functions perfectly in my Chrome/Firefox style sheet, but unfortunately, it does not have any effect on my IE stylesheet. # ...

The Div element seems to have a mind of its own, refusing

Check out my code on this link: http://jsfiddle.net/Pd7nm/ I'm trying to make the sidebar stop scrolling with the page once it reaches a certain point, but it just won't cooperate. I've attempted various solutions, but none seem to be effec ...

Position a div at the center of the page while aligning it inline with another div

Is there a way to center an element on the screen while having another element positioned to its left? I have tried using float left and adjusting the padding of the center element to match the width of the left element. However, this method may not work ...

Optimal method for storing large arrays of numbers in localStorage using JavaScript

*"Efficient" in this context refers to smaller size (to reduce IO waiting time) and fast retrieval/deserialization times. Storing times are less important in this scenario. I need to store multiple arrays of integers in the browser's localStorage, ea ...

Safari doesn't seem to recognize z-index property

Currently, I am utilizing a responsive template to develop a website. An issue arises in Safari where the footer overlaps the navigation bar at the bottom of the page, despite being positioned above it earlier. It appears that the z-index attribute is not ...

Variations in the implementation of responsive web design on laptops versus mobile devices

Looking at the css code below: @media only screen and (min-width: 0px) and (max-width: 768px) { ... } I'm curious about why, on my laptop, when I resize the browser window to exactly 768px, the css properties inside this media query are applied. ...

Using JavaScript to dynamically load Cascading Style Sheets based on the current

I am trying to dynamically load different CSS files based on the current date (season). I attempted to tweak an image script that I found on Stack Overflow, but it didn't yield the desired result. Could someone please guide me on where I might be ma ...

Retrieving Time Format from JSON Within an Angular.js Application

Whenever I receive app data through an API in JSON format, the time stamps always come back looking less than desirable. They appear like this: 2013-11-25T12:44:02 In my Angular app, I haven't found a straightforward way to format these time stamp ...

Desktop keyboards are essential for inputting data into HTML fields that are not

I'm currently working on developing an on-screen keyboard. My goal is to prevent the mobile device keyboard from opening while the on-screen keyboard is active. One approach is to make the input read-only so that it doesn't open the keyboard when ...

Create an event listener for clicking on an image that potentially has a corner ribbon obscuring a portion of it

In my project, there is a div element with an id of items containing several bootstrap cards. Each card includes an image tag and some are accompanied by the following HTML code: <div class="ribbon"><span>Sale</span></div> This co ...

Strong tags within MFC

Is it possible to create labels in MFC (Static text) that contain both bold and non-bold text? For instance, something like this: "I want my label to have a mix of styles like this" Any suggestions on how to achieve this? I am aware that I can change ...

Adapt button functionality according to selected dropdown value in Angular

I have implemented a License Key generation process in my application where user input is used to create a unique key that is then passed to the Java backend. The code snippet for generating the key is as follows: @PostMapping("/generate") public Li ...

What is preventing me from modifying the icon on a dropdown menu?

I've been struggling to change my dropdown icon from the default "carrot" to a Fontawesome one. Despite researching other questions, I still can't find a solution that works for me. <form> <div class="form-group"> <select disab ...

Adjusting Flexbox Sidebar to Match Content Height

I'm facing an issue with my layout where the sidebar sometimes becomes taller than the page body, extending beyond the screen height and continuing to expand vertically. Here's a snippet of my code structure: <div class="fb-col"> < ...

Stop the div from overflowing

I am currently in the process of developing a unique horizontal animated page transition system which involves scaling the screen to fit the incoming page. However, I have encountered an issue where if the new page is smaller than the previous one, it caus ...

I am experiencing issues with my button not responding when I click on the top few pixels

I've created a StackBlitz version to illustrate the issue I'm facing. It seems like the problem might be related to my CSS for buttons... Essentially, when you click on the button at the very top few pixels, it doesn't register the click an ...

Retrieve several values with a limit of 1 in SQL

Consider the following table structure: ID | ident | product 1 | cucu1 | 99867 | 2 | kkju7 | 88987 | 3 | sjdu4 | 66754 | 4 | kjhu6 | 76654 | 5 | cucu1 | 98876 | Running the query: SELECT ident,COUNT(*) FROM sales WHERE status=? AND team=? AND DATE(da ...

Emphasize the CSS property and give it top priority

I am struggling with setting the highest priority for the background of the <h1> element. Specifically, I want the background color specified for the <h1> to show instead of what is specified for the <a> element. h1{ background-color:b ...

The CSS animation initially encounters a glitch before ultimately running smoothly as planned

I am currently working on a basic webpage that will showcase a list of disciplines. When a discipline is selected, relevant information will be displayed below. The code snippet available here demonstrates the functionality I am aiming for. However, I hav ...

How can I customize the appearance of the file input button in Angular Material?

Despite browsing numerous similar questions, I have yet to find a solution to my issue. My setup includes Angular 11, Angular Material 8, and a file input structured like this: <div class="form-group"> <input #myInput type="fil ...