简体   繁体   English

设置div填充z-index

[英]Set div padding z-index

Is it possible to set the z-index of the padding of a specific div ? 是否可以设置特定div的填充的z-index

I'm using particle.js as an interactive background that changes with mouse position. 我将particle.js用作随鼠标位置变化的交互式背景。 However, this only works when the canvas is at the top of the stack. 但是,这仅在画布位于堆栈顶部时才有效。 I am using a div container for the main content with a padding of 10% . 我正在使用div容器作为主要内容, padding10%

I'd like this padding to be sent backwards on the stack so that the mouse can interact with the background. 我希望将此padding向后发送到堆栈上,以便鼠标可以与背景交互。

So I managed to solve this by removing the padding and margins of the div and using relative position with the same spacings as the margin previously. 因此,我设法通过除去div的填充和边距并使用与以前的边距具有相同间距的相对位置来解决此问题。 I then set the canvas z-index to 1 with the container div z-index to 2. 然后,将画布的z-index设置为1,将容器div z-index设置为2。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM