Z-index behaving abnormally

I've been working on developing a website and one of the key features I'm trying to implement is a slideout menu that slides horizontally when the mouse hovers over it. To make development easier, I initially set the menu to be fully extended by default.

Here's an example of what I'm aiming for:

|--------------|_____________
|Menu 1       >|Menu 1 item 1|
|Menu 2       .|Menu 1 item 2|
|Menu 3       .|Menu 1 item 3|
|______________|_____________|

This is the code I have so far:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
@charset "utf-8";
/* CSS Document */

#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    background: #151515;
    width: 250px;
    height: 100%;
    z-index: 2;
    overflow-x: hidden;
    overflow-y: hidden;
    display: block;
    transition: 0.5s;

}

#sidebarInfo{
    margin: 0px,5px,10px,5px;
    color: #7E7E7E;
    width: 100%;
    height: 50px;
    position: relative;
    font-family: allerta, sans-serif;
    font-size: 9.5px;
    top: 70%;
    align-content: center;
    display:flex;
    justify-content:center;
    align-items:center;
}

.sidebarLi{
    position: relative;
    margin: 10px;
    font-size: 28px;
    color: aliceblue;
    width: 100%;
    font-family: allerta, sans-serif;
}

.slideMenu{
    position:relative;
    transition:0.4s;

}
.menuItem{
    position:relative;
    transition: 0.4s;
    width: 150px;
    height: 30px;
    overflow-x: visible;
    overflow-y: visible;
    left: 180px;
    z-index: 0;
    color: #000000;
    background: #FFFFFF;
}

</style>

<title>Caduceus Technologies</title>

</head>

<body>
    <div id="sidebar">
        <div class="sidebarLi">
            &nbsp;•&nbsp;Home
        </div>
        <div class="sidebarLi">
            <div class="slideMenu">
                &nbsp;•&nbsp;Projects
                <div class="menuItem">
                    menuItem1
                </div>
            </div>
        </div>
        <div class="sidebarLi">
            &nbsp;•&nbsp;Resume
        </div>
        <div class="sidebarLi">
            &nbsp;•&nbsp;Contact
        </div>
    </div>
    <div style="background:#1D1D1D; position: relative; width:1000px; height: 1000px;">
        Lorem
    </div>
</body>
</html>

But despite setting the Z value correctly, when viewing the document you'll notice that 'menu Item 1' is not fully displayed. What could be causing this issue?

Answer №1

menuItem1 appears cut off because the sidebar div enclosing it has a fixed width and is set to overflow: hidden, therefore hiding any content that extends beyond its boundaries (including menuItem1).

If you remove the overflow: hidden property, menuItem1 will be visible but may extend outside the container's borders.

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

Hide the selection box when hovering over the Div

Looking for a quick solution. I want the option drop down to close when another div element is hovered over. First, open the drop down and hover over the red element on the right side. When hovering over the red element, I would like the drop down to clos ...

cusel.js encountered an error due to attempting to use the 'in' operator to search for 'using' within the specified error

I attempted to implement the cusel.js (styled selects) library on my select elements, but unfortunately it's not functioning as expected. The selects change visually, however when I try to scroll through the options using jscrollpane, an error that I ...

Is it possible for browser sync to replace a CSS file hosted on a CDN upon injection?

Trying to solve a dilemma with my Shopify theme. Working on my Shopify theme, I find it frustrating that I have to constantly save my CSS changes, switch tabs, and reload the browser to see updates. While I know about the theme gem, it doesn't provid ...

Show a div pulsating while simultaneously animating another div

After coming across this query on Stack Overflow about adding a class without jQuery if hovering over another class I encountered an issue with a div element that displays upon hovering over a span, which was functioning correctly. However, I also have a ...

MaterialUI Box reigns supreme in the realm of background images

In my React component, I have a form that is structured like this: <Box display="flex" justifyContent="center" alignItems="center" style={{ minHeight: "100vh", backgroundColor: "gray", opacity: "0.8" }} > ... </Box> ...

Convert PHP function output to HTML element

Check out the content of my Class.php file: <?php class Class { public function validate() { if(empty($_POST['first_name'])) { return 'first name should not be empty!'; } elseif(em ...

Transform the inline style attributes found in the HTML code into CSS styling

After creating a webpage using Bootstrap Studio, I realized that all the style attributes are inline and I want to move them to a separate CSS file. However, I am facing difficulty in doing so as when I add an image using 'background-image:url('i ...

What's the reason for the element not inheriting margins from its parent?

I am facing an issue with centering an h1 header within a .banner element. When I try to apply margin to the header, it appears to indent not from the top border of the banner, but rather from the nav element located above the banner. After inspecting the ...

Discover additional and subtract options

I am trying to implement a "See more" and "See less" button functionality for my list items inside an unordered list using the code below, but it is not working as intended. $(document).ready(function() { var list = $(".partners__ul li"); var numTo ...

Having trouble keeping the HTML text centered within the div on a responsive layout

Having an issue with keeping text centered in the middle of a div that overlaps an image. It looks fine on desktop but when I try to make it mobile-friendly, things go haywire. I believe the problem lies in using fixed heights for the div, as setting heigh ...

Limiting the character input in ion-textarea within Ionic 2: A step-by-step guide

In my Ionic 2 application, I need to limit user comments to less than 500 characters in a text area. What is the best way to implement this restriction? ...

Experience a captivating Bootstrap 4 drop menu animation that emerges from beyond the borders of the page

I have a row that contains two divs, one with col-md-11 and the other with col-md-1. Inside the col-md-1 div, there is a dropdown that I want to animate. I am using animate css for the animation, but the issue is that the slideInRight animation starts from ...

Utilizing JavaScript to dynamically set the height and width of a canvas based on the user input

How can I take user input for height and width values and apply them to a newly created canvas? I am able to retrieve the values, but I'm unsure how to set them as the style.height and style.width properties. var createNewCanvas = document.getEleme ...

How come I am unable to vertically align my elements with bootstrap?

Currently, I am in the process of developing a windsurfing website. Despite utilizing classes such as justify-content-center, align-items-center, and text-center, I am facing an issue where the h1 and h2 elements remain positioned at the top and are not ve ...

I am encountering an issue where my Vue navbar is successfully changing the route but not updating the corresponding router-view

I have been working on a single-page application using Vue and I encountered an issue with the navbar when navigating through routes. The problem is that after the first click on a navbar item, the route changes successfully but the router-view does not up ...

What is the best way to adjust the size of the circles in my d3 leaflet implementation based on the frequency of longitude/latitude pairs?

I'm currently diving into the world of d3 and attempting to create a map using leaflet. Within my dataset, I have thousands of latitude and longitude coordinates. While I've successfully plotted circles on a leaflet map in d3, I'm now faced ...

Player using unexpected options instead of Video.js options

I have created a basic HTML page with a small JavaScript snippet to function as a playlist, and it was working perfectly fine. However, when I integrated Video.js into the mix, an issue arose. Sometimes, upon reopening the page, the player fails to load p ...

Is the default choice for the dropdown list set to Razor?

I am encountering an issue with a Razor declaration that results in a duplicated element in a drop-down menu. The code in question is as follows: @Html.DropDownList("SelectedRole", ViewBag.RolesEdit as List<SelectListItem>, ViewBag.CurrentUserRole a ...

Ways to incorporate margins into text on PDF pages produced by Puppeteer without altering the background color

I am currently using puppeteer to generate PDFs that contain dynamic content. My goal is to include margins/padding above and below the text on consecutive pages. Unfortunately, when I try to add margins with the property margin: { top: "1cm", bottom: "1 ...

What are some alternative methods for downloading the latest file version without relying on the client cache?

On my webpage, I have a table displaying users' data. Each row represents a user and includes their business card, which is a clickable tag that opens a PDF file stored on the server. <td class="business_card"> <a href="/static/users_doc ...