Expansive mega dropdown menu across the entire width of the desktop screen, neatly contained

Is there a way to create a mega menu within the navigation list element that spans the full width of the page without using JavaScript? Right now, I'm facing an issue where the mega menu is relative to its parent and I want it aligned flush with the left edge of the entire page.

Currently, my mega menu is aligned to the first nav item rather than spanning the full width that I desire.

Can anyone suggest a non-JavaScript solution for this matter?

Below is the attached image showing the current layout:

Link to a quick fiddle:

<div class="header">
  <div class="container">
    <div class="row">
      <div class="col-xs-3 logo">Logo</div>
      <div class="col-xs-6 nav">
        <ul>
          <li>
            <a href="#">Link 1</a>
            <div class="mega-menu">
              This needs to be full width.            
            </div>
          </li>
          <li><a href="#">Link 1</a></li>
          <li><a href="#">Link 1</a></li>
        </ul>
      </div>
      <div class="col-xs-3 secondary-nav">Other links</div>
    </div>
  </div>
</div>

.header {
  width: 100%;
}

.container {
  background-color: #ccc;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.nav ul {
  display: inline-block;
}

.nav ul li {
  display: block;
  float: left;
  margin-right: 20px;
}

.nav ul li a {
  background-color: #888;
  color: #fff;
}

.nav .mega-menu {
  background-color: #aaa;
  display: block;
  height: 500px;
  position: absolute;
  top: 35px;
  width: 100vw;
}

Answer №1

Include the following code in your .nav .mega-menu's css file:

.nav .mega-menu {
  position: absolute;
  top: 50px;
}

Here is the demonstration on jsfiddle: https://jsfiddle.net/c754asdn/12/

Answer №2

If you want the .nav element to remain in its original position, you can include "position: static;" in your CSS. When elements are set to absolute positioning, they become fixed within their closest parent elements that do not have a static position.

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

Laravel Tutorial: Utilizing for and foreach Loops to Showcase Data in Blade Template

I am trying to use a for and foreach loop to display data based on a template table. However, I am running into an issue where the else conditions always display an index of their own. My expectation is as follows: https://i.stack.imgur.com/tqDSn.png Th ...

Safari does not support onunload when the page is closing

<body onunload="notReady()"> <script > function notReady(){ alert("closing") } </script> </body> It seems that the script works only when refreshing the page or clicking a link on the page, but not when closing the pa ...

When I type in the TextBox, the CheckBox value should be deactivated if it is unchecked

Whenever I attempt to input text into the textbox associated with my checkbox, the checkbox automatically becomes unchecked. How can I prevent this from happening? <span id="TRAVEL_TYPE_1"><input id="TRAVEL_TYPE_0" type="checkbox" onclick="Update ...

Guide to Implementing h-100 Class in Bootstrap 4

I am facing an issue with the height of the sidebar in my admin panel. Despite trying to set the sidebar's height to 100%, I have been unsuccessful in solving this problem. <html class="h-100"> <head> <title>Admin</title> ...

Utilizing Angularjs to create repetitive patterns in each table row

After tirelessly searching the depths of the internet, I have yet to come across a solution to my dilemma. No answer, direct or indirect, seems to guide me towards a resolution. My goal is to embed multiple forms within a table, with each row enclosed in ...

Is it not possible to apply CSS box-shadow to divs on top of an image or video

Why does the box shadow on my content divs not mix with my superbgimage/jw player background? Instead of darkening, it creates a grey halo effect. Do box-shadows only work on white backgrounds? Halo effect instead of shadow blending with background image ...

JavaScript Error Caused by Newline Characters

I'm facing an issue with extracting data from a textbox using JavaScript. What I'm attempting to do is retrieve the value from a textbox, display it in an alert, and then copy it. Here's the current code snippet: var copyString = "Date: < ...

Issue with splitting a JavaScript function in JQuery within the Wordpress platform can cause errors

My split function seems to be causing an error, as shown in this console error image. There is a hidden input field within the PHP file: <input class="file-id" name="_file-id" type="hidden" value="<?php echo esc_attr($file_ids); ?>" /> I hav ...

Using Nginx to run both PHP and Node.js, with PHP files using the .php extension and Node.js files using the .html extension

Hello, I am trying to configure my server to handle PHP files and HTML files on the same server. Specifically, I want HTML files to be handled by Node.js on port 8080, while PHP files are handled by the PHP5 service. Here is the Nginx configuration I have ...

Using Django Form with Bootstrap: Incorporating CSS classes and <div> elements

I am currently implementing Twitter Bootstrap with Django to style forms. Bootstrap can enhance the appearance of forms, but it requires specific CSS classes to be included. My challenge lies in the fact that Django's generated forms using {{ form.a ...

"Marquee animation functions correctly on the emulator but fails to display on the physical

Greetings! I recently incorporated a marquee tag into my application, and it functions properly in the Android simulator. However, once I install it on my device, the marquee does not display. Below is the code I used for the marquee: <marquee behavi ...

Which specific CSS stylesheet do LinkedIn, Facebook, and Quora utilize for their websites?

I've been curious about how websites like Linkedin, Facebook, or Quora design their sites. When I view them in responsive mode in my browser, I noticed that the content stays fixed at 1000px or 1100px and doesn't change. However, when I access th ...

I am interested in implementing a "slide up" effect for the "slide menu" when it loses focus

When I focus out of the asmenu class, I attempt to trigger a 'slide up' effect. However, if I select two checkboxes from the child elements within the asmenu class, the focusout event is still triggered. Ideally, I would like the 'slide up& ...

Error loading custom Javascript in MVC 4 view during the first page load

I'm working on an MVC 4 application that utilizes jQuery Mobile. I have my own .JS file where all the functionality is stored. However, when I navigate to a specific view and check the page source, I notice that all scripts files are loaded except fo ...

Exploring CSS Images, Graphics, and Typography in the Laravel 4 Framework

I am encountering some difficulties with setting up my assets in the Laravel 4 Framework. To provide some context, I have an assets folder within my public directory, containing subfolders for css, images, and fonts. Here are the paths: /laravel-master/pu ...

Expanding Items' Widths in ItemsControl on Silverlight

I am facing an issue with my ItemsControl where the child items are not occupying the whole width of the control: My goal is to stretch the green bits to fill the width of the control, similar to how the blue bits are shown. I have attempted adjusting th ...

"Kindly complete all mandatory fields" - The undisclosed field is preventing me from submitting

I am facing an issue with my WordPress page that has Buddyboss installed along with Elementor pro as the Pagebuilder. The Buddyboss plugin provides Facebook-like functions on the website. While it is easy to comment on posts within the Buddy Boss system, I ...

JavaScript mouse and touch movement events (mousemove, pointermove, touchmove) are not always accurate

I'm currently working on developing a JavaScript whiteboard and have implemented the following code: let lastTimestamp = 0; const fps = 1000/60; document.addEventListener("pointermove", moveMouse, false); function moveMouse (e) { e.preve ...

What is the process for customizing the arrow of a <select> dropdown menu exclusively?

Here is the code for a dropdown menu: <select id="dropdown"> <option value="">Go to page...</option> <option value="http://stackoverflow.com">CSS-Tricks</option> <option valu ...

Double-up with Bootstrap's dual-column tabs

Looking to customize the layout of a nav-tabs ul to display its contents in 2 columns instead of horizontally, as per the default Bootstrap style for nav-tabs. Attempted to use the CSS property column-count: 2 but it didn't yield the desired result. ...