Content OverFlow: DropDown Menu is not overlapping the content, but rather pushing it downwards

In my webpage, I have a drop-down menu that traditionally pushes the content below it down to make space for its items. However, I want the drop-down to overlap the contents below without affecting their position.

I've tried various solutions, such as applying z-index: 1; to the drop-down list, but nothing seems to work as intended.

  <td valign="top" class="navigationLink" style="width: 20%" >

                    <div class="reportDiv">
                        <h:outputLabel value="Report" rendered="#{welcomeBean.report}" class="reportMenu"/>


                        <ul class="reportUL" >
                            <li><h:link value="Project Wise Report" outcome="/webpages/ProjectWiseReport.xhtml" rendered="true" class="reportItems"/></li>
                            <li><h:link value="Employee Wise Report" outcome="/webpages/EmployeeWiseReport.xhtml" rendered="true" class="reportItems"/></li>
                        </ul>
                    </div>
                    </td>    

This drop-down constitutes one row of a table within which I've placed the webpage's contents. When I click on the My Account label, the ul drops down, increasing the height of the table row and pushing the one below it down. My goal is to have the drop-down overlapping the next row's contents instead.

Additional code snippets above and below this segment

 <div class="container">
            <table border="0" cellpadding="2" style="width: 100%;">

                <tr style="background-color: #95D0CA;">
                    <td colspan="2">
                   </td>
                </tr>

           <tr style="position: relative; z-index:1;">
            <td colspan="2" valign="top">

         <table border="0" cellspacing="2" cellpadding="2" class="templateBody" style="width: 100%;">

                <tr >

               <td> 
              </td>

          
               <td valign="top" class="navigationLink" style="width: 20%" >

                    <div class="reportDiv">
                        <h:outputLabel value="Report" rendered="#{welcomeBean.report}" class="reportMenu"/>


                        <ul class="reportUL" >
                            <li><h:link value="Project Wise Report" outcome="/webpages/ProjectWiseReport.xhtml" rendered="true" class="reportItems"/></li>
                            <li><h:link value="Employee Wise Report" outcome="/webpages/EmployeeWiseReport.xhtml" rendered="true" class="reportItems"/></li>
                        </ul>
                    </div>
                    </td>    

                     </tr> 
              </table>
           </td>
        </tr> 

       
        <tr>

           <td colspan="2" valign="top" style="width: 100%">

             <div class="contentBody">

             </div>

          </td>
        </tr> 

      </table>
        </div>      

I'll provide some snapshots to illustrate the issue better and seek your guidance accordingly.

Pre-drop-down expansion image: !(https://i.stack.imgur.com/p1vFX.jpg)

Image showing the appearance after expanding the drop-down: !(https://i.stack.imgur.com/GTNkI.jpg)

I attempted using jsFiddle as suggested by many, but it did not display my code correctly, hindering the troubleshooting process.

Please assist me with resolving this issue, and let me know if you require additional scripts or details. **Thank You in Advance :)**

**Edit**

Inclusion of CSS and JavaScript codes

CSS Code corresponding to the provided markup:

 .navigationLink a
 {
  background-color: #95D0CA;
  margin-top: 5px;
  margin-bottom: 5px;
 }

 .navigationLink label
 {
 background-color: #95D0CA;
  margin-top: 5px;
 margin-bottom: 5px;
 }


   .reportMenu
   {
   text-decoration: none;
    color: #216961;
   font-weight: bold;
   font-size: 15px;
   display: block;
   padding: 10px 5px 10px 5px;
   text-align: center;  
   cursor: pointer;
   }

 .reportItems
 {
    color: white; 
    text-decoration: none;
    font-weight: 400;
    font-size: 15px;
    padding: 10px;
   background-color: #95D0CA;
   text-align: center;
 }

  .container
  {
   width: 1000px;
   background-color: whitesmoke;
   padding: 10px;
   margin: 50px auto;
   position: relative;
  }

 .templateBody
 {
    font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
    width: auto;
 }

 .templateBody td
 {
    text-align:center;
 }

 .contentBody
 {
    background-color: whitesmoke;           
    margin: 10px 0px 10px 0px;
    width: 100%;
    position: relative;
    clear: both;
 }

   .reportUL
 {
   list-style-type: none;
    position: absolute;
   z-index: 1;
    padding: 0;
   margin: 0;
   text-align: left;

 }

 .reportUL li
 {
  background-color: #95D0CA;
 }

JQuery Script :

 $(document).ready(function()
    {   
       //Some JQuery functions here
    });

Answer №1

Check out the examples below for some creative ideas.

Here are a couple of stylish drop down menus that you can create:

Example 1

Example 2

Answer №2

To ensure the drop down menu works correctly, I made sure to include the following CSS properties in the reportUL class for the unordered list (ul):

The key property needed to position the drop down menu over the contents below is:

 position: absolute;

In order to display the drop down menu above or on top of the underlying content, I utilized:

z-index: 1;

The final and accurate CSS code for the class is as follows:

     .reportUL
{
   list-style-type: none;
    position: absolute;
   z-index: 1;
    padding: 0;
   margin: 0;
   text-align: left;

}

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

Exploring the mocking of document,hidden using Jasmine

Struggling to simulate document.hidden in an angular unit test, but facing issues. Tried the following solutions: spyOn(Document.prototype, <any>'hidden').and.returnValue(true); spyOn(Document, <any>'hidden').and.ret ...

Ways to expose a components prop to its slotted elements

I've set up my structure as follows: <childs> <child> <ul> <li v-for="item in currentData">@{{ item.name }}</li> </ul> </child> </childs> Within the child component, t ...

To enable the radio button upon clicking the list item in JavaScript, simply check the radio button

I am working with radio buttons Here is the HTML code: <input type="radio" class="first" name="bright" checked> <input type="radio" class="second" name="bright" > <input type=" ...

How come "display:none" is still occupying space on the page?

Trying to figure out how to make a specific cell in a table disappear when viewing an HTML page on mobile devices, while having a width of 20% for desktop. However, the issue is that even though the table cell is invisible on mobile, it still occupies sp ...

What is the process of accessing JSON data transmitted from a Express server in JavaScript?

Working with a node server, I've set up a client-server model, meaning the client connects to "localhost" and express generates a response based on certain logic. While I'm able to send a JSON object through the response, I'm unsure of how t ...

Core-pages with polymer core have no set height limit

I am embarking on my first project using Polymer. I have implemented core-pages to facilitate navigation between different pages. However, I am facing an issue where the pages are not displaying with a white background-color as intended in the css. You ca ...

Version 2: "In case of an empty input field, the submit button should be

After experimenting with two different codes on my websites, I encountered an issue. The first code looked like this: $(document).ready(function(){ $('.sendButton').attr('disabled', true); $('#message').keyup(function ...

Javascript and CSS combo for creating a stylish fade effect

Hey everyone, I have a design challenge where I need to change the color of a picture inside a box when the user hovers over it. I have four boxes like this and my goal is to make everything else fade out when a user hovers over a specific box. Anyone kn ...

Passing data to server-side PHP script using AJAX technology

Currently, I'm facing an issue with passing variables to a PHP script using onclick. It seems that I am making a mistake somewhere. To demonstrate the problem, let's say I have the following code snippet in my main page: <img src="myImage.jp ...

JavaScript Mouseover Custom Trigger with d3.js Library

Currently, I am experimenting with d3.js and am interested in creating a custom event with a unique trigger. From my understanding, the 'mouseover' event occurs when the mouse pointer hovers over a specific element both horizontally and vertical ...

The history.push function seems to be leading me astray, not bringing me back

Issue with History.Push in Register Component App function App() { const logoutHandler = () =>{ localStorage.removeItem("authToken"); history.push("/") } const [loading, setLoading]= React.useState(true) useEffect(()=>{ ...

Securing Codeigniter against CSRF attacks with AJAX integration

Seeking assistance to troubleshoot a problem with AJAX call in Codeigniter while having CSRF protection enabled. Typically, the system functions smoothly with AJAX/jQuery calls and CSRF protection. However, I am currently facing difficulties with the code ...

Challenges in the Knockout Framework Due to Synchronization Issues

Recently, I've encountered a slight problem with race conditions in my code. Utilizing Knockout.Js to collect information for user display has been the cause. The issue arises when a dropdown needs to be created before a value can be selected. Typica ...

Tips for keeping a floating action button visible at the bottom of the screen at all times

I am currently utilizing the Material UI framework. I have a floating action button that I would like to display in a specific position on the page without it moving when scrolling, and I am also wondering if this is a common issue. Below is the code sn ...

Vue: Duplicating a div element with unique input fields upon clicking

I have successfully set up a page where I can dynamically add a div/row of inputs by clicking the link. This feature works smoothly and adds the same div below the current one with all the proper inputs. Additionally, one of the inputs is designed as an a ...

What is the best way to give stacked bar charts a rounded top and bottom edge?

Looking for recommendations on integrating c3.js chart library into an Angular 6 project. Any advice or suggestions would be greatly appreciated! ...

If I change the request mode to 'no-cors' in my Firebase cloud function, how will it impact the outcome?

After encountering an issue with the Firebase inbuilt password reset functionality, I created a Firebase function to handle OTP verification and password changes based on the correctness of the OTP. The function is designed to validate the OTP provided, ch ...

Step-by-step guide to implementing a sticky header while scrolling

How can I implement a fixed header on scroll, like the one seen on this website: www.avauntmagazine.com Here is the HTML for my header: <div class="bloc bgc-wild-blue-yonder l-bloc " id="bloc-1"> <div class="container bloc-sm"> &l ...

Error: The code is trying to access the property 'string' of an undefined variable. To fix this issue, make sure to

I encountered an issue after installing the https://github.com/yuanyan/boron library. The error message I received is: TypeError: Cannot read property 'string' of undefined Error details: push../node_modules/boron/modalFactory.js.module.expor ...

Different from Window.Print()

I am looking to implement a print button that will trigger the printing of the entire webpage when clicked. I have been attempting to achieve this using Window.print() in JavaScript, but I encountered an issue where the link stops working if the print bu ...