Whether the navigation is trimmed with overflow:hidden or continues onto the next line

Hey everyone, I've been struggling with the navigation on a website I'm currently developing. My goal is to have a fixed height for the navigation bar while still incorporating dropdown menus. Despite spending countless hours trying different solutions, I haven't been able to achieve the desired outcome.

The issue I'm facing is illustrated here: http://jsfiddle.net/88fYK/482/

CSS:

.top_nav {
    background-image: url('images/navbg.gif');white-space:nowrap;
    height:32px;
    }

.top_nav #menu{
height:32px;
    overflow:hidden;
}
.top_nav #menu ul{
float:left;
padding:0;
margin:0;
line-height:30px;

}
.top_nav #menu li{
position:relative;
float:left;
list-style:none;
background:rgba(0,0,0,1);
border-radius:5px;
}
.top_nav #menu ul li ul{
position:absolute;
display:none;
padding:0;
margin:0;
top:30px;
white-space:nowrap;
}
.top_nav #menu ul li a{
text-align:center;
font:"Arial Black", Arial;
font-size:24px;
color:rgba(255,255,255,9);
width:150px;
height:30px;
display:block;
text-decoration:none;

}
.top_nav #menu ul li:hover{
background-color:rgba(128,128,128,1);
text-decoration:none;
}
.top_nav #menu ul li:hover ul{
display:block;
z-index:1;
}
.top_nav #menu ul li:hover ul li a{
background:rgba(0,0,0,9);
z-index:1;
border-bottom:1px solid rgba(160,160,164,1);
opacity:0.9;
text-decoration:none;
border-radius:5px;
}
.top_nav #menu ul li ul li:hover{
background:rgba(128,128,128,1);
opacity:0.8;
text-decoration:underline;
}

HTML:

<div class="top_nav">
<div id="menu">

<ul>
<li><a href="#">Home</a></li> 
<li><a href="#">Video</a>    <!--This is in main menu-->
<ul> 
<li><a href="#">Technology</a></li>    <!--This is in drop downmenu-->
<li><a href="#">Tutorial</a></li>     <!--This is in drop downmenu-->
</ul>
</li>
<li><a href="#">link</a><ul> 
<li><a href="#">sub</a></li>    <!--This is in drop downmenu-->
<li><a href="#">sub</a></li>     <!--This is in drop downmenu-->
</ul></li> 
<li><a href="#">link</a><ul> 
<li><a href="#">sub</a></li>    <!--This is in drop downmenu-->
<li><a href="#">sub</a></li>     <!--This is in drop downmenu-->
</ul></li> 
<li><a href="#">link</a></li> 
<li><a href="#">link</a></li> 
<li><a href="#">link</a></li> 
<li><a href="#">link</a></li> 
<li><a href="#">link</a></li> 
<li><a href="#">link</a></li> 
<li><a href="#">link</a></li> 

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

However, I need the dropdown menus to function like in this example: http://jsfiddle.net/88fYK/484/ (with the removal of 'overflow:hidden;')

The primary issues I encounter are: - The navigation wrapping (which is not acceptable) - The dropdown menus not working as intended I've experimented with various CSS properties such as float, position, and clearfix but haven't found a successful solution yet. Any assistance or guidance you can provide would be greatly appreciated.

Answer №1

Basically, I just added the following code:

.top_nav #menu>ul>li {
    display: inline-block;
}

and made a few adjustments by removing some floats.

If you want to see it in action, check out this demo: http://jsfiddle.net/xaqzvevf/

By the way, the CSS declaration targets all li elements that are descendants of a ul which is a child of an element with the id of #menu.

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

What is the best way to incorporate an image into the background of an HTML email?

My goal is to design an automated email script for sending birthday wishes. However, I am facing a challenge in setting up the background image for the email content. I want the image to be displayed behind the text, similar to how it appears on certain we ...

React Download Button: Easy way to offer file downloads on

I am trying to create a download button for users to download zip files from Cloudinary using React. I have attempted different methods to implement this feature, but so far, I have been unsuccessful. Whenever I click on the button, it modifies the route i ...

Solving the mystery of background color in CSS for heading/title div

I am facing an issue with the title div setup where the red background is not applied when only the leftmost div has content. Despite the 'title' div having content, the background remains white. Can anyone suggest why this might be happening? H ...

Enhancing JQuery UI Accordion with simple ICONS

Is it necessary to use the Jquery CSS file for adding icons, or is there an alternative method? I'm hoping I can avoid using it as I am working within Wordpress and enqueuing the Jquery CSS seems like a complex task for me. Apologies for the basic q ...

Can you explain how to pause the .setInterval() function when hovering over it and clicking on the interior content simultaneously?

I have been working on a slideshow that involves building elements into an array, modifying the DOM, and using items from the array to fade in and out on a timer. While I have made progress, there are still a few things I would like to accomplish but I am ...

How to retrieve the clientX value of a mousemove event on an HTML progress element using

Help needed in implementing a fully functional video progress bar. Here is the code snippet: html <video class="video" width="612" height="350" preload="none" controls controlsList="nodownload" oncontextmenu="return false;"> <source src="vi ...

Modifying a div element upon the successful completion of an ajax/json request

Currently, I have a form on my webpage for creating a new album. Alongside this form, there is also a delete album form. After successfully creating an album, I want to automatically update the checkbox list in the delete album form with the details of the ...

Adding new rows and columns to a table in Vue using scoped CSS styling

Trying to populate a table with rows and columns programmatically by using this code: addContentToTable(type) { switch (type) { case "row": let numOfColumns = this.$refs.table.rows[0].cells.length; let row = this.$refs.table.insertRow(-1 ...

Using the <video> element is creating a gap between itself and the element following it

I am facing an issue with a video background on my webpage. The video is perfectly positioned, but it is creating a large gap between itself and the next element. Despite checking for margins or paddings in the inspection tool, I cannot seem to find the so ...

The function "onClick" within an external .js file is being referenced

Just starting to learn Javascript and experimenting with an onClick event for an image in an external .js file using the HTML tag. <script type="text/javascript" src="embed.js"> The code found in "embed.js" is as follows: var image1=new Image(); i ...

Show MySQL SELECT output on a HTML page

I have created a button that opens a new .html page in a new browser tab, allowing users to input data that is then stored in a MySQL database using a PHP script. Now, I am looking for a way to display the content of my MySQL database on my index.html fil ...

Ember JS's solution for a fixed footer that sticks to the

I am working on an Ember.js application and have been attempting to create a sticky footer, but I am encountering some issues. Here is my HTML setup: <div class="main-container" id=""> <header> HEADER </header> <div class="conta ...

Guide onsetting up an Autocomplete textbox on a webpage using data from a database by utilizing a combination of Java servlet, jQuery, JSON objects, and an ajax request

Despite trying various methods, I am struggling to achieve this task. As a beginner in the realms of jQuery, JSON, and AJAX, I have written a servlet that connects to my database and fetches user IDs from a specific table. Additionally, I have designed a J ...

display picture on a Vue-powered webpage

<main id="meals"> <h3 style="text-align: center;">Week 1 - Day 1</h3> <h6>{{mealType}} ( {{selectedItems}}/{{maxSelection}} selected )</h6> <div class="grid"> ...

Is it possible to dynamically append and delete rows of interconnected dropdown menus?

I'm currently working on a form that allows users to add and remove rows with cascading dropdowns for class selection. Everything is functional except for the feature to remove selected classes. I've experimented with different methods like the ...

What is the best way to transfer a data string from my HTML document to my server (using either Node or Express) and trigger a specific function with that data?

Currently, my node.js server is operational and successfully creating an excel document by fetching data from an API using Axios. Now, I am looking to implement a feature where users can input a string on my HTML page, which will then be sent to the web se ...

Updating CSS class within a div tag utilizing ASP.NET (C#)

How can I dynamically update the properties of a CSS class using C#? I need to change the background image, font size, font style, and font based on user input through an interface. Once the changes are saved, I store them in a database. However, when the ...

Creating a right triangle with a background filled with linear gradients: tips and tricks

Looking to create a right triangle with a linear-gradient background color in CSS? Wondering if it's possible? Check out the code I currently have for a right triangle with a single background color. You can also find the same code here. <style&g ...

Green and red values hovering within the keyframe

Currently, I'm facing a dilemma involving keyframes. I have a table populated with values retrieved from a JSON fetch and need to implement a hover effect where values less than 5 show in red, while those equal to or greater than 5 appear in green. Be ...

React Issue: Footer not staying attached at the bottom of the page

I'm currently developing a website with react, but I'm struggling to keep the footer at the bottom. When there isn't enough content, the footer ends up right after the content instead of staying at the bottom. I've tried various solutio ...