简体   繁体   English

即使 z-index 为 9999,react 元素也会被隐藏

[英]react element is hidden even with z-index of 9999

I am working on a jsfiddle react sidebar project, and have it so the sidebar can expand/collapse dynamically based on how much screen size you have.我正在开发一个 jsfiddle react 侧边栏项目,并拥有它,以便侧边栏可以根据您拥有的屏幕尺寸动态展开/折叠。 I want the button for sidebar expand/collapse to always be visible though, so I added it to my sidebar and gave the element a left:xxxpx attribute, but the "CLICKME," button to expand/collapse the sidebar is always hidden under the main content, even after I've added z-index:99999!important to try and make sure the button is always visible我希望侧边栏展开/折叠的按钮始终可见,所以我将它添加到我的侧边栏并给元素一个 left:xxxpx 属性,但是用于展开/折叠侧边栏的“CLICKME”按钮总是隐藏在主要内容,即使我添加了z-index:99999!important以确保按钮始终可见

in css my element has these attributes:在 css 我的元素具有以下属性:

/* Style the `label` that we use to target the `.sidebar-checkbox` */
.sidebar-toggle {
    left:230px;
    z-index:999999!important;
    
  position: absolute;
  top: 1rem;
  display: block;
  padding: 0.5rem 0.65rem;
  color: #505050;
  background-color: #fff;
  border-radius: 4px;
  cursor: pointer;
}

But the button remains partially hidden under the main content, is there any way I can make this "CLICKME?"但是按钮仍然部分隐藏在主要内容下,有什么办法可以使这个“CLICKME”? button always on top of the main content?按钮总是在主要内容之上?

https://jsfiddle.net/martinradio/04tryqwk/14/ https://jsfiddle.net/martinradio/04tryqwk/14/

.sidebar-toggle {    
  position: absolute;
  right: 1rem;
  display: block;
  padding: 0.5rem 0.65rem;
  color: #505050;
  background-color: #fff;
  border-radius: 4px;
  cursor: pointer;
}

Above css takes care of the partially hidden issue.上面的 css 处理了部分隐藏的问题。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Z-index:9999 的 Div 被 iframe 隐藏,z-index:-1 IE8- - Div with z-index: 9999 being hidden by iframe with z-index: -1 IE8- 即使鼠标隐藏在更多 z-index 元素后面,也会调用较低 z-index 的鼠标悬停 - mouse over of lower z-index is called even when its hidden behind the more z-index element animationModal.js对话框使链接不可单击(即使它具有z-index:-9999) - Dialog box of animatedModal.js makes link not clickable (even though it has z-index:-9999) 即使将元素设置为自动,如何确定元素的z-index - How to determing z-index of element even when they are set to auto 子菜单被隐藏,并且z-index无效 - Submenu is hidden and z-index has no effect 即使整个img通过z-index与另一个元素重叠,也可以使其可点击吗? - Is it possible to make an entire img clickable even if it is overlapped by another element through z-index? 即使有一些解决方法或黑客措施,是否也可以为div的子元素更改z-index? - Is it possible to change z-index for a child element of a div even with some workarounds or hacks? z-index放置元素位于另一个元素之下,即使该元素较高 - z-index placing element below another one even though its higher 单击更改其他元素的Z索引 - Changing Z-Index Of Another Element On Click 获取页面上每个元素的Z索引 - Get Z-index of each element on the page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM