The navigation bar has surpassed the content limit and overflow-y is visible

My website has a navigation bar with content that exceeds the desired limit, and I want the rest of the content to be shown in overflow-y.

However, an issue arises when hovering over the content, as the content is displayed (likely due to fixing min-height).

Below is the code snippet and a FIDDLE for reference:

    <div id="centernav">
    <div id="dropnav">
        <ul>
            <li id="main">
            <a href="#">Menu Item 1</a>
            </li>

            <li id="main">
            <a href="#">Menu Item 2</a>
                <ul id="subnav">
                      <li><a href="#">sub menu item 1</a></li>
                      <li><a href="#">sub menu item 2</a></li>
                      <li><a href="#">sub menu item 3</a></li>
                      <li><a href="#">sub menu item 4</a></li>
                </ul>            
            </li>

            ...

        </ul>    
    </div>
</div>

CSS

/* CSS Styles */ 
 #pagebody {
    position: inherit !important;
    width: 100%;
}
 #pagebody-inner {
    position: inherit !important;
    width: 100%;
}
 #alpha, #beta, #gamma, #delta {
    display: inline;
    position: inherit !important;
    float: left;
    min-height: 1px;
}
#centernav {
    width: 900px;
    margin-left: auto;
    margin-right: auto;
}
...

If you have any suggestions for a scalable solution and, if possible, a way to remove the default scroll, please let me know.

Thank you!

Answer №1

Your coding approach could be improved by using classes instead of ids for the li tags labeled as 'main', as ids should be unique on a page.

If you simply want to remove the scroll bar from Menu 3, you can achieve this by adding 'overflow: visible;' to your inline script.

However, it is advisable to move this inline code to your style sheet for better organization.

I have made some updates to your jsfiddle to align it with your desired layout.

Here are the CSS modifications:

Your CSS code here...

And here is the updated HTML structure:

Your HTML code here...

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

Tips for causing a single span tag within a group of multiple tags to overflow its parent element

Is there a way to make the highlight span sit just after the to without affecting the width of the parent, and without using absolute positioning? I would like the span to be aligned with the example "to" and overflow outside of the parent container. Thank ...

Data is not displaying correctly in the Angular Material Table

I'm currently trying to build a mat table based on an online tutorial, but I'm facing a problem where the table appears empty even though I have hard coded data. As someone new to Angular and HTML/CSS, I'm struggling to understand why the ma ...

What is the best approach to repurpose a component when small adjustments are needed?

Can a customized slider component be created in React that can be reused with slight variations? For example, having the second one include a 13% field. View image description here ...

Leveraging the power of JavaScript Math methods to dictate the Co-ordinates of HTML Canvas .fillRect

Greetings to everyone! I have dedicated my entire evening to understanding how to implement the (Math.floor(Math.random()) function as the coordinates for the .fillRect method on an HTML canvas element. Despite searching through this website and various ...

What is the best way to modify the CSS of a child element within the context of "$(this)"

On my search results page, each result has an icon to add it to a group. The groups are listed in a hidden UL element on the page with display:none. The issue I'm facing is that when I click on the icon for one result, the UL appears under every sing ...

Develop a container element with protective measures against external CSS styles impacting internal elements

As I work on integrating my webpage code into a large project, I have encountered an issue. The entire project code is contained within a div element inside the <main> tag. However, when I add this container div within the <main> tag, the pro ...

Is the accuracy of Chrome's inspect device not up to par?

I'm currently testing how the page appears on a 1366x768 laptop. When inspected in the device, it looks perfect: https://i.sstatic.net/OECnx.png However, on the actual laptop screen, it's completely off: https://i.sstatic.net/chaeY.png It&ap ...

Unknown identifier in the onClick function

I want to create a JavaScript function that can show or hide a paragraph when clicking on an arrow. The challenge I'm facing is that I have a list of titles generated in a loop on the server, and each title is accompanied by an arrow. Initially, the c ...

In Vue.js, leverage the power of slots to access content from deeply nested child components

Recently, I came across this example: This child component serves as the foundation for all the components that follow. <template> <div class="content-box"> <div class="boxtitlecontainer titleColor"> <slot name="title"> ...

Can you explain the purpose of the .col-form-label class in Bootstrap and how it affects labels?

Here in the initial label, the class is specifically identified. <form> <div class="form-group row"> <label for="staticEmail" class="col-sm-2 col-form-label">Email Address</label> <div ...

The fusion of PHP and HTML coding

I have been attempting to integrate some PHP code into a combination of HTML and I am facing some challenges. Below is the code I am working with: <?php $result = mysqli_query($db,"SELECT * FROM classes"); while($record = mysqli_fetch_array($result)) ...

Detecting the specific button that was selected with PHP

I am in the process of developing a website for a production company where, upon clicking on a director's name from the menu, all other menu items disappear and only the selected director's biography and work are displayed. My current challenge ...

Issue with custom select functionality on Internet Explorer 9

Having some issues with a select element in IE9. The links that should open the wiki page are not functioning properly only on IE9, and there is also an issue with the hover effect - the icon gets overridden by the background color when hovering over help ...

Finding a predecessor with Selenide through tag and class identification

Trying to find the ancestor element using Selenide library on a website. The ancestor element is <div class="BorderGrid-cell" ...>. The .closest(".BorderGrid-cell") method works well. However, the .closest("div.BorderGrid-ce ...

Steps to creating an elliptical border using CSS

Is there a way to apply CSS styles specifically to the left border of a div to achieve an elliptical shape, while keeping other borders normal? I've managed to create a semi-ellipse with the following code, but the rest of the border remains unchanged ...

Using data binding in VueJS to construct a dynamic URL

Exploring VueJS for the first time and it's been a great experience so far. However, I'm facing a couple of challenges with data binding. The requirement is for the customer to input an image URL, and no image should be displayed until a valid ...

The high chart data is failing to load

I am brand new to highchart and have just started learning how to create a simple pie chart in HTML. Unfortunately, I am having trouble getting it to work properly. Everything seems correct to me, but for some reason, the highchart is not populating. Here ...

Utilizing JavaScript to target a specific div element and modify the href attribute

I am currently working on adjusting the links within my page using JavaScript. While I am able to select the div and the a element, I am encountering difficulties in changing the href attribute. Shopify utilizes a for loop to generate these objects, and i ...

The iframe content is not updating despite using jQuery

On this site , the following code is present: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <iframe style="position: absolute; top: 0; left: 0; height: 100%; width: 100%" src="blank.html"></iframe ...

Adjusting the length of the To, CC, and BCC text fields in web design

I'm developing a webpage that will collect email addresses for user notifications. I want to ensure the length limits of the 'to,' 'cc,' and 'bcc' fields. According to RFC 2821/3696, an email address can be up to 256 cha ...