Looking to expand the width of the sub menu to reach the full width of the

Is there a way to use CSS to make a sub-menu start from the left side of the screen instead of starting it below the parent item?

nav {
     margin: 0 auto;
     text-align: center;
}
 nav ul ul {
     display: none;
}
 nav ul li:hover > ul {
     display: block;
}
 nav ul {
     list-style: none;
}
 nav ul li {
     float: left;
}
 nav ul li:hover a {
     color: #000000;
     margin-bottom:5px;
     border-top: 1px solid #000000;
     border-bottom: 1px solid #000000;
}
 nav ul li a {
     display: block;
     padding: 5px 15px;
     color: #000000;
     text-decoration: none;
}
 nav ul ul {
     border-radius: 0px;
     padding: 0;
     position: absolute;
}
 nav ul ul li {
     float: none;
     position: relative;
}
 nav ul ul li a {
     color: #000000;
}
 nav ul ul li a:hover {
     color: #666666;
}
 nav ul ul ul {
     position: absolute;
     top:0;
}
<nav>
   <ul>
      <li>
         <a href="/view_contacts.php">Contacts</a>
         <ul>
            <li><a href="add_contact.php">Add Contact</a></li>
            <li><a href="view_contacts.php">View Contacts</a></li>
         </ul>
      </li>
      <li>
         <a href="/tickets.php">Tickets</a>
         <ul>
            <li><a href="new_ticket.php">New Ticket</a></li>
            <li><a href="tickets.php">View Tickets</a></li>
         </ul>
      </li>
      <li><a href="/invoices.php">Invoices</a></li>
      <li><a href="/itemised_calls.php">Itemised Calls</a></li>
   </ul>
</nav>

Here is a jsfiddle link for demonstration, hope it helps! : http://jsfiddle.net/jhmkqrye/1/

Currently, the sub-menu for "Tickets" starts from below the ticket, but I want it to begin below "Contacts" from the start of the screen width to the end of the screen width.

Answer №1

To achieve the desired effect, consider setting the parent element's position to relative and the child elements' to absolute. Then you can specify the positioning using left, right, bottom, top.

As an illustration, setting left: 0; would position your child item all the way to the left.

Update: Is there a potential issue with the jsfiddle link? I couldn't locate any sub-menu upon hovering, and when clicked, it leads to a 404 error page.

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

Is there a way to modify the appearance of a text box to suit individual preferences?

Is it possible to alter the shape of a text box, creating a rectangle with a portion removed from one side? I have included an example image for reference. I came across clip-path: polygon in CSS, but it seems to only accept four coordinates. Thank you i ...

Accessing properties in JavaScript using square brackets

When I input the following code into my Chrome console: var object = {0:0, 1:1} I am able to retrieve the values by calling object[0] and object[1]. Surprisingly, even when I use object["0"] and object["1"], I still get the same results. Then, if I redef ...

Breakpoint for mobile menu in FoundationCSS

When the browser is resized, the mobile menu appears at 568x320, which is the default breakpoint. https://i.sstatic.net/ZSbiq.jpg I would like to create a breakpoint around 900px to address the issue with the menu being too large as shown in the image be ...

Tips for troubleshooting and resolving the npm ERR! code E404 issue in Vue.js when implementing a datepicker

I am a newcomer to Vue.js and I am currently exploring the use of a datepicker from However, upon importing the script for usage, I encountered the following message: 'VMdDateRangePicker' is declared but its value is never read.ts(6133) Cou ...

What is the correct way to establish the value of an editable div element?

When working with input and other elements that have a value, I usually use Object.getOwnPropertyDescriptor(input, 'value').set; followed by element.dispatchEvent(new Event('input', {bubbles: true})). However, this approach does not wor ...

The back to top feature is malfunctioning when navigating to a new page

I've been working with jQuery Mobile to create some pages and wanted to add a "back to top" element. It's been functioning well, but I've encountered an issue. When I navigate from one page, let's say #sport, back to #restaurants after ...

Issue with selecting multiple items in DataTables using the shift key

Currently, I am working with datatable 1.10 and have successfully created a table. However, I am unable to enable the multiple "shift select" functionality for its rows. Referring to the official DataTables documentation: The TableTools plugin offers fou ...

Adding content in real-time at the current cursor position within a Contenteditable element using Angular

I have a contenteditable div where I am facing an issue with pasting text. Whenever I try to paste some text into the div, it always gets pasted at the end. I am using ViewChild to access the reference of the contenteditable div and utilizing innerText to ...

What is the best way to change an object into a string in node.js?

Recently, I've delved into the world of node js and I'm eager to create a basic coap client and server using this technology. Successfully, I managed to set up a server hosting a text file, but now I aim to access it from the client. var coap = ...

Calculate the total of all values associated with a dynamically generated key within an array of objects

I'm trying to calculate the sum of similar keys in an array of objects. Each object in the array will have some common keys, but not all arrays will share the same set of keys. I'm considering storing these keys in a separate array and then loopi ...

JQuery Scroll Spy Implementation

I have structured the page with a header at the top and 3 columns below. The left column contains a menu, the middle column is a text container, and the right column is another section. As the page scrolls up, the menu becomes fixed in position which func ...

What is the best way to retrieve the results of an indexedDb request beyond the limitations of its callback function?

I am working on a form that has an input box which I want to auto-complete with values from an IndexedDb objectStore. Currently, it is functioning with two overlapping input boxes, using a simple array. However, I am looking to make it work with the values ...

Learn the best practices for incorporating jQuery and other JavaScript libraries in your Angular2 projects

Is it possible to integrate a demo showcasing Bootstrap carousel with CSS3 animations in Angular2 using HTML, CSS, and JS? I have created my own implementation in Plunker with Angular2, but I am facing issues with the animated inner content of the carousel ...

Hitting the enter button won't initiate a search

Why isn't the search event triggered by pressing the enter key, but it works when manually clicking the Search button? Here is a simple script I am using: $('#searchproductbrand').live('click',function() { var search = $(&apos ...

What could be causing this JSON object error I'm experiencing?

res.send({ customerDetails:{ fName, lName, }, applicantDetails:{ [ {primaryApplicant:{fName1,lName1}}, {secondaryApplicant:{fName2,lName2}}, {thirdA ...

What is the best method to store the name of an image as a session variable?

<!--images acting as buttons--> <form> <img src="peanuts.jpg"" class="qac left" onclick="qac_search()" name="Peanuts"> <img src="milk.jpg" class="qac" onclick=&qu ...

appending a set of parameters to a website address

I am currently developing an app in a Node/Express/Jade environment. Imagine that I launch my app and navigate my browser to the following URL: /superadmin/?year=2012 Upon reaching this page, I encounter a list of objects sorted in a default order. Ther ...

unable to receive input value

<script type="text/javascript" language="javascript"> $(function() { $("#distributor").autocomplete({ source: function(request, response) { $.ajax({ url: "/Devices/autoDistributor", ...

Tips for displaying animations only the first time using HTML and CSS:

Upon the initial visit to my website, a captivating animation introduces itself with the words "Hello. I'm Bob" as it gracefully fades into view. Navigating through the menu bar allows users to explore different sections of the site. However, there ...

Is there a problem with addEventListener returning false?

What does keeping the third parameter as false in the line below signify? var el = document.getElementById("outside"); el.addEventListener("click", modifyText, false); ...