I struggle with managing a z-index in conjunction with an absolute position

Check out this codesandbox to see the issue where the 3 dots button is displayed over the menu. Click on the 3 dots to understand the problem.

Below is the CSS code for the menu:

.more-menu {
  position: absolute;
  top: 100%;
  z-index: 900;
  float: left;
  width: fit-content;
  margin-top: 29px;
  margin-left: calc(50% - 45px);
  background-color: #fff;
  border: 1px solid #ccd8e0;
  border-radius: 4px;
  box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.25);
  opacity: 0;
  -webkit-transform: translate(0, 15px) scale(0.95);
  transform: translate(0, 15px) scale(0.95);
  transition: transform 0.1s ease-out, opacity 0.1s ease-out;
  pointer-events: none;
}

.more-dot {
  background-color: #d7262c;
  margin: 0 auto;
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 3px;
  border-radius: 50%;
  transition: background-color 0.3s;
}
<div class="show-more-menu">
  <button id="more-btn">
    <span class="more-dot" />
    <span class="more-dot" />
    <span class="more-dot" />
  </button>
  <div class="more-menu" aria-hidden="true">
    <div class="more-menu-caret">
      <div class="more-menu-caret-outer" />
      <div class="more-menu-caret-inner" />
    </div>
  </div>
</div>

Answer â„–1

Implementing the transform property on your container elements is creating a unique stacking context, which is then passed down to the nested more containers. Since your buttons and menus are placed as siblings, the z-index value does not affect their positioning in relation to each other. To resolve this issue, consider removing the transform from your .container elements and exploring alternative methods of achieving the desired layout. Unfortunately, I'm unsure of the specific outcome you're aiming for to provide a tailored suggestion.

I created a modified version link, where I eliminated the transform and top: 100% properties from the menu. As a result, it now aligns centrally while maintaining the stacking order you envisioned.

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 make the <iframe> adjust its size as the element it contains grows, without

Seeking assistance with a specific issue. My goal is to have an iframe appear on hover of another element and expand with it. The problem I'm facing is that the iframe shows up quickly and extends beyond its parent container. Here's what I have: ...

Angular does not employ any Bootstrap styles when rendering

I have successfully installed both Ngb and Bootstrap 4 using the commands provided below, with the root module importing the package as well. npm install @ng-bootstrap/ng-bootstrap --save npm install bootstrap@next --save Within my code, I am attem ...

Tips for customizing the appearance of popup windows

I want to enhance the appearance of my popup window by applying a different format for opening it. How can I style it so that it looks visually appealing when the popup window opens? You can find below the source code I am working with: HTML: <div onM ...

Switch up text using jQuery on css-tricks.com

I am having trouble with the code I found on a page about toggling text using jQuery from this link. Could someone please explain to me the significance of ':visible'? Thank you. Here is the fiddle link, and below is the code that I copied. Vi ...

Tips for toggling the visibility of a revolution slider based on current time using JavaScript

Currently, I am integrating the revolution slider into my WordPress website. My goal is to have the slider change according to the standard time of day. For instance, I want slider1 to display in the morning, slider2 at noon, slider3 in the evening, and sl ...

Different ways to alter the color of contextual color classes in Bootstrap 5

Currently working on my project with Bootstrap 5, I've been incorporating elements featuring classes such as btn-primary and text-success. In Bootstrap, the -primary class is associated with blue, while -success corresponds to green, among others. I&a ...

What causes the presence of a boundary around the svg?

I have been encountering an issue while attempting to incorporate my logo into the header of my webpage. Specifically, when viewed on smaller screens, I noticed that there is a margin surrounding the SVG image. Below is my HTML file: <html lang="e ...

Complete Navigation Bar Expands Alongside Drop-down Menu

For my navbar, I am attempting to set a custom breakpoint at 1080px where it switches to a hamburger menu. However, when I click on a dropdown option, the entire navbar expands instead of just the dropdown area. @media (min-width: 1080px){ .navbar-expand- ...

Using jQuery, learn how to successfully call a selector from dynamic content

I am currently facing a challenge with a table that is generated server-side and then appended to the view page (client-side). Since the table is not directly included in the DOM, I am using the StickyTableHeaders jQuery plugin to create a sticky header fo ...

Adjust the background color of the header as you scroll

Seeking assistance in adjusting the background color of my header upon scrolling. This is my current implementation: header.component.ts export class HeaderComponent { ngOnInit(): void { const header = document.querySelector('.header'); ...

The children's className attribute can impact the parent element

As I work on creating a card object, I envision it with the className .card that is styled in CSS as follows: .card img{position:absolute; width:150px; height:160px} I want only the images inside my div to overlap each other while not affecting the divs ...

Issue: Keeping the mat-form-field element in a single line

I am facing an issue with incorporating multiple filters for each column in an angular material table. I cannot figure out why the filter input is not moving to a new line under the header. Here is an image for reference -> Angular material table with m ...

css issues with setting background colors

I am in the process of updating the header on a website, and I want the entire header to have a light gray background. My initial approach was to set the background-color of the main header div to gray (E7E7E7), but for some reason, there is now a white sp ...

What is the best way to position the publication date of an article at the bottom of the

I am looking to have the article publishing date (1/9/2016) positioned at the bottom inside the container. Right now, the date appears just below the text, but I want it to be aligned at the bottom of the container. The website in question is watchathletic ...

Designing a drop-down selection interface

http://jsfiddle.net/367ms/1/ I need assistance with my code. My goal is to have a blue border that appears 10 px below the text when hovered over. Additionally, I have a submenu that opens on hover, but it automatically closes when trying to navigate down ...

in Vue.js, extract the style of an element and apply it to a different element

Currently, I am using VUE.js 2 in my project. Here is my website's DOM structure: <aside :style="{height : height()}" class="col-sm-4 col-md-3 col-lg-3">...</aside> <main class="col-sm-8 col-md-9 col-lg-9" ref="userPanelMainContents" ...

Ignoring CSS transitions by changing the width property in JavaScript’s element.style

When attempting to create a smooth progress bar animation by adjusting the width using document.querySelector('#mydiv').style.width = '20%', I noticed that the new width is updated instantly rather than transitioning smoothly. It seems ...

Dynamic styling updates on page refresh in Next.js

There is a strange issue with my styling that I can't seem to figure out. I have a NavBar set to be 20vh in height and an image set to be 100% in width. However, whenever I refresh the page, the NavBar height decreases and the image width increases si ...

The font size appears significantly smaller than expected when using wkhtmltoimage to render

I am trying to convert text into an image, with a static layout and size while adjusting the font size based on the amount of text. I prefer using wkhtmltoimage 0.12.5 as it offers various CSS styling options. Currently, I am working on a Mac. Below is a ...

How to Align Navigation Bar Items to the Right in Bootstrap 4

I need some help with bootstrap. I've looked at various discussions on this topic and tried numerous solutions, but I still can't get it right. I want the logo to be on the left and the navigation links aligned to the right. Here's what I&ap ...