[英]Accordion Panels wont open (how do i keep div behind others)
Im making a personal website here and i need a div in the background that goes from the top to the botton. 我在这里制作个人网站,我需要在后台从顶部到底部的一个div。 (In this case its the one named 'sidebar' and is red.) When i added this it kinda broke the accordion panels i had. (在这种情况下,其名称为“ sidebar”,为红色。)当我添加此名称时,它有点破坏了我的手风琴面板。 Im guessing its something with the z-index, or position relative. 我猜测它与z-index或相对位置有关。 Or maybe i need to add a z-index to all for them to make them come to top. 或者,也许我需要为所有对象添加一个z-index才能使其达到最高水平。 Not sure, any help would be appreciated. 不确定,任何帮助将不胜感激。
CSS fo the sidebar div: 侧边栏div的CSS:
#sidebar{
height: 720px;
width: 270px;
background-color: red;
z-index: -1;
position: relative;
}
Here is a FIDDLE: https://jsfiddle.net/dvr2pm6x/ 这是一块: https ://jsfiddle.net/dvr2pm6x/
You have z-index: -1;
您有z-index: -1;
on #sidebar
. 在#sidebar
。 That will put it behind body
and any other element it might overlap that has either no z-index
or a higher z-index
, which makes #sidebar
unclickable. 它将放置在body
和可能重叠的其他任何元素之后,这些元素没有z-index
或更高的z-index
,这使#sidebar
无法点击。 Just to illustrate, you can set position: relative; z-index: -2;
只是为了说明,您可以设置position: relative; z-index: -2;
position: relative; z-index: -2;
on body
and then you can click #sidebar
. 在body
,然后您可以单击#sidebar
。 demo . 演示
Remove the negative z-index
and #sidebar
will be clickable. 删除负的z-index
,# #sidebar
将可单击。 https://jsfiddle.net/dvr2pm6x/3/ https://jsfiddle.net/dvr2pm6x/3/
You would want to make the sidebar position as absolute. 您可能希望将边栏的位置设为绝对。 here is the fiddle https://jsfiddle.net/dvr2pm6x/1/ 这是小提琴https://jsfiddle.net/dvr2pm6x/1/
#sidebar{
height: 720px;
width: 270px;
background-color: red;
z-index: -1;
position: absolute;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.